Another batch...
This commit is contained in:
@@ -87,6 +87,7 @@ int asizetab[] = {
|
||||
void oldline(line_p lnp);
|
||||
void oldargb(argb_p abp);
|
||||
void oldreg(reg_p rp);
|
||||
void oldargs(arg_p ap);
|
||||
|
||||
/*
|
||||
* alloc routines:
|
||||
@@ -131,7 +132,7 @@ arg_p newarg(int kind)
|
||||
return(ap);
|
||||
}
|
||||
|
||||
void ldargs(arg_p ap)
|
||||
void oldargs(arg_p ap)
|
||||
{
|
||||
arg_p next;
|
||||
|
||||
|
||||
@@ -21,14 +21,19 @@ static char rcsid[] = "$Id$";
|
||||
* Author: Hans van Staveren
|
||||
*/
|
||||
|
||||
flow() {
|
||||
void findreach();
|
||||
void reach(line_p lnp);
|
||||
void cleaninstrs();
|
||||
|
||||
void flow()
|
||||
{
|
||||
findreach(); /* determine reachable labels */
|
||||
cleaninstrs(); /* throw away unreachable code */
|
||||
}
|
||||
|
||||
findreach() {
|
||||
register num_p *npp,np;
|
||||
void findreach()
|
||||
{
|
||||
num_p *npp,np;
|
||||
|
||||
reach(instrs);
|
||||
for(npp=curpro.numhash;npp< &curpro.numhash[NNUMHASH]; npp++)
|
||||
@@ -51,8 +56,9 @@ findreach() {
|
||||
}
|
||||
}
|
||||
|
||||
reach(lnp) register line_p lnp; {
|
||||
register num_p np;
|
||||
void reach(line_p lnp)
|
||||
{
|
||||
num_p np;
|
||||
|
||||
for (;lnp != (line_p) 0; lnp = lnp->l_next) {
|
||||
if(lnp->l_optyp == OPNUMLAB) {
|
||||
@@ -88,9 +94,10 @@ reach(lnp) register line_p lnp; {
|
||||
}
|
||||
}
|
||||
|
||||
cleaninstrs() {
|
||||
register line_p *lpp,lp,*lastbra;
|
||||
bool reachable,superfluous;
|
||||
void cleaninstrs()
|
||||
{
|
||||
line_p *lpp, lp, *lastbra;
|
||||
bool reachable, superfluous;
|
||||
int instr;
|
||||
|
||||
lpp = &instrs; lastbra = (line_p *) 0; reachable = TRUE;
|
||||
|
||||
@@ -46,6 +46,16 @@ int CBO_instrs[] = {
|
||||
/* don't add op_mli and op_mlu! */
|
||||
};
|
||||
|
||||
|
||||
void enter(char *name, int value);
|
||||
void yyerror(char *s);
|
||||
void printnodes();
|
||||
void initio();
|
||||
void outpat(int exprno, int instrno);
|
||||
void outbyte(int b);
|
||||
void outshort(int s);
|
||||
void out(int w);
|
||||
|
||||
int patCBO;
|
||||
int rplCBO;
|
||||
%}
|
||||
@@ -242,8 +252,9 @@ struct hashmnem {
|
||||
byte h_value;
|
||||
} hashmnem[HASHSIZE];
|
||||
|
||||
inithash() {
|
||||
register i;
|
||||
void inithash()
|
||||
{
|
||||
int i;
|
||||
|
||||
enter("lab",op_lab);
|
||||
enter("LLP",op_LLP);
|
||||
@@ -255,8 +266,9 @@ inithash() {
|
||||
enter(em_mnem[i],i+sp_fmnem);
|
||||
}
|
||||
|
||||
unsigned hashname(name) register char *name; {
|
||||
register unsigned h;
|
||||
unsigned int hashname(char *name)
|
||||
{
|
||||
unsigned int h;
|
||||
|
||||
h = (*name++)&BMASK;
|
||||
h = (h<<4)^((*name++)&BMASK);
|
||||
@@ -264,8 +276,9 @@ unsigned hashname(name) register char *name; {
|
||||
return(h);
|
||||
}
|
||||
|
||||
enter(name,value) char *name; {
|
||||
register unsigned h;
|
||||
void enter(char *name, int value)
|
||||
{
|
||||
unsigned int h;
|
||||
|
||||
h=hashname(name)%HASHSIZE;
|
||||
while (hashmnem[h].h_name[0] != 0)
|
||||
@@ -274,8 +287,9 @@ enter(name,value) char *name; {
|
||||
hashmnem[h].h_value = value;
|
||||
}
|
||||
|
||||
int mlookup(name) char *name; {
|
||||
register unsigned h;
|
||||
int mlookup(char *name)
|
||||
{
|
||||
unsigned int h;
|
||||
|
||||
h = hashname(name)%HASHSIZE;
|
||||
while (strncmp(hashmnem[h].h_name,name,3) != 0 &&
|
||||
@@ -284,8 +298,8 @@ int mlookup(name) char *name; {
|
||||
return(hashmnem[h].h_value&BMASK); /* 0 if not found */
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
inithash();
|
||||
initio();
|
||||
yyparse();
|
||||
@@ -294,20 +308,21 @@ main() {
|
||||
return nerrors;
|
||||
}
|
||||
|
||||
yyerror(s) char *s; {
|
||||
|
||||
void yyerror(char *s)
|
||||
{
|
||||
fprintf(stderr,"line %d: %s\n",lino,s);
|
||||
nerrors++;
|
||||
}
|
||||
|
||||
lookup(comm,operator,lnode,rnode) {
|
||||
register expr_p p;
|
||||
int lookup(int comm, int operator, int lnode, int rnode)
|
||||
{
|
||||
expr_p p;
|
||||
|
||||
for (p=nodes+1;p<lastnode;p++) {
|
||||
if (p->ex_operator != operator)
|
||||
continue;
|
||||
if (!(p->ex_lnode == lnode && p->ex_rnode == rnode ||
|
||||
comm && p->ex_lnode == rnode && p->ex_rnode == lnode))
|
||||
if (!((p->ex_lnode == lnode && p->ex_rnode == rnode) ||
|
||||
(comm && p->ex_lnode == rnode && p->ex_rnode == lnode)))
|
||||
continue;
|
||||
return(p-nodes);
|
||||
}
|
||||
@@ -320,20 +335,22 @@ lookup(comm,operator,lnode,rnode) {
|
||||
return(p-nodes);
|
||||
}
|
||||
|
||||
printnodes() {
|
||||
register expr_p p;
|
||||
void printnodes()
|
||||
{
|
||||
expr_p p;
|
||||
|
||||
printf("};\n\nshort lastind = %d;\n\nexpr_t enodes[] = {\n",prevind);
|
||||
for (p=nodes;p<lastnode;p++)
|
||||
printf("/* %3d */\t%3d,%6u,%6u,\n",
|
||||
printf("/* %3ld */\t%3d,%6u,%6u,\n",
|
||||
p-nodes,p->ex_operator,p->ex_lnode,p->ex_rnode);
|
||||
printf("};\n\niarg_t iargs[%d];\n", (maxpatlen>0 ? maxpatlen : 1));
|
||||
if (patid[0])
|
||||
printf("static char rcsid[] = %s;\n",patid);
|
||||
}
|
||||
|
||||
initio() {
|
||||
register i;
|
||||
void initio()
|
||||
{
|
||||
int i;
|
||||
|
||||
printf("#include \"param.h\"\n#include \"types.h\"\n");
|
||||
printf("#include \"pattern.h\"\n\n");
|
||||
@@ -374,9 +391,9 @@ initio() {
|
||||
curind = 1;
|
||||
}
|
||||
|
||||
outpat(exprno, instrno)
|
||||
void outpat(int exprno, int instrno)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
outbyte(0); outshort(prevind); prevind=curind-3;
|
||||
out(patlen);
|
||||
@@ -399,20 +416,20 @@ outpat(exprno, instrno)
|
||||
if (patlen>maxpatlen) maxpatlen=patlen;
|
||||
}
|
||||
|
||||
outbyte(b) {
|
||||
|
||||
void outbyte(int b)
|
||||
{
|
||||
printf(",%3d",b);
|
||||
curind++;
|
||||
}
|
||||
|
||||
outshort(s) {
|
||||
|
||||
void outshort(int s)
|
||||
{
|
||||
outbyte(s&0377);
|
||||
outbyte((s>>8)&0377);
|
||||
}
|
||||
|
||||
out(w) {
|
||||
|
||||
void out(int w)
|
||||
{
|
||||
if (w<255) {
|
||||
outbyte(w);
|
||||
} else {
|
||||
|
||||
@@ -28,6 +28,8 @@ static char rcsid[] = "$Id$";
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
int optimize();
|
||||
|
||||
#define ILLHASH 0177777
|
||||
short pathash[256]; /* table of indices into pattern[] */
|
||||
|
||||
@@ -39,8 +41,8 @@ byte transl[op_plast-op_pfirst+1][3] = {
|
||||
/* SEP */ { op_SEP, op_ste, op_sde }
|
||||
};
|
||||
|
||||
opcheck(bp) register byte *bp; {
|
||||
|
||||
void opcheck(byte *bp)
|
||||
{
|
||||
if (((*bp)&BMASK) >= op_pfirst)
|
||||
*bp = transl[((*bp)&BMASK)-op_pfirst][opind];
|
||||
}
|
||||
@@ -54,11 +56,12 @@ opcheck(bp) register byte *bp; {
|
||||
* Estimated improvement possible: about 2%
|
||||
*/
|
||||
|
||||
hashpatterns() {
|
||||
void hashpatterns()
|
||||
{
|
||||
short index;
|
||||
register byte *bp,*tp;
|
||||
register short i;
|
||||
unsigned short hashvalue;
|
||||
byte *bp,*tp;
|
||||
short i;
|
||||
short hashvalue;
|
||||
byte *save;
|
||||
int patlen;
|
||||
|
||||
@@ -121,7 +124,8 @@ hashpatterns() {
|
||||
}
|
||||
}
|
||||
|
||||
peephole() {
|
||||
int peephole()
|
||||
{
|
||||
static bool phashed = FALSE;
|
||||
|
||||
if (!phashed) {
|
||||
@@ -131,9 +135,10 @@ peephole() {
|
||||
return optimize();
|
||||
}
|
||||
|
||||
optimize() {
|
||||
register num_p *npp,np;
|
||||
register instr;
|
||||
int optimize()
|
||||
{
|
||||
num_p *npp,np;
|
||||
int instr;
|
||||
bool madeopt;
|
||||
|
||||
madeopt = basicblock(&instrs);
|
||||
@@ -152,15 +157,16 @@ optimize() {
|
||||
return madeopt;
|
||||
}
|
||||
|
||||
offset oabs(off) offset off; {
|
||||
|
||||
offset oabs(offset off)
|
||||
{
|
||||
return(off >= 0 ? off : -off);
|
||||
}
|
||||
|
||||
line_p repline(ev,patlen) eval_t ev; {
|
||||
register line_p lp;
|
||||
register iarg_p iap;
|
||||
register sym_p sp;
|
||||
line_p repline(eval_t ev, int patlen)
|
||||
{
|
||||
line_p lp;
|
||||
iarg_p iap;
|
||||
sym_p sp;
|
||||
offset diff,newdiff;
|
||||
|
||||
assert(ev.e_typ != EV_UNDEF);
|
||||
@@ -226,7 +232,8 @@ line_p repline(ev,patlen) eval_t ev; {
|
||||
}
|
||||
}
|
||||
|
||||
offset rotate(w,amount) offset w,amount; {
|
||||
offset rotate(offset w, offset amount)
|
||||
{
|
||||
offset highmask,lowmask;
|
||||
|
||||
#ifndef LONGOFF
|
||||
@@ -241,10 +248,11 @@ offset rotate(w,amount) offset w,amount; {
|
||||
|
||||
eval_t undefres = { EV_UNDEF };
|
||||
|
||||
eval_t compute(pexp) register expr_p pexp; {
|
||||
eval_t compute(expr_p pexp)
|
||||
{
|
||||
eval_t leaf1,leaf2,res;
|
||||
register i;
|
||||
register sym_p sp;
|
||||
int i;
|
||||
sym_p sp;
|
||||
offset mask;
|
||||
|
||||
switch(nparam[pexp->ex_operator]) {
|
||||
@@ -252,15 +260,15 @@ eval_t compute(pexp) register expr_p pexp; {
|
||||
assert(FALSE);
|
||||
case 2:
|
||||
leaf2 = compute(&enodes[pexp->ex_rnode]);
|
||||
if (leaf2.e_typ == EV_UNDEF ||
|
||||
nonumlab[pexp->ex_operator] && leaf2.e_typ == EV_NUMLAB ||
|
||||
onlyconst[pexp->ex_operator] && leaf2.e_typ != EV_CONST)
|
||||
if ((leaf2.e_typ == EV_UNDEF) ||
|
||||
(nonumlab[pexp->ex_operator] && leaf2.e_typ == EV_NUMLAB) ||
|
||||
(onlyconst[pexp->ex_operator] && leaf2.e_typ != EV_CONST) )
|
||||
return(undefres);
|
||||
case 1:
|
||||
leaf1 = compute(&enodes[pexp->ex_lnode]);
|
||||
if (leaf1.e_typ == EV_UNDEF ||
|
||||
nonumlab[pexp->ex_operator] && leaf1.e_typ == EV_NUMLAB ||
|
||||
onlyconst[pexp->ex_operator] && leaf1.e_typ != EV_CONST)
|
||||
if ((leaf1.e_typ == EV_UNDEF) ||
|
||||
(nonumlab[pexp->ex_operator] && leaf1.e_typ == EV_NUMLAB) ||
|
||||
(onlyconst[pexp->ex_operator] && leaf1.e_typ != EV_CONST))
|
||||
return(undefres);
|
||||
case 0:
|
||||
break;
|
||||
|
||||
@@ -363,7 +363,7 @@ void outsym(sym_p sp)
|
||||
{
|
||||
byte *p;
|
||||
unsigned int num;
|
||||
warning("May do something nasty... (%s)", __func__);
|
||||
printf("May do something nasty... (%s)", __func__);
|
||||
if (sp->s_name[0] == '.') {
|
||||
num = atoi(&sp->s_name[1]);
|
||||
if (num < 256) {
|
||||
|
||||
@@ -21,9 +21,10 @@ static char rcsid[] = "$Id$";
|
||||
* Author: Hans van Staveren
|
||||
*/
|
||||
|
||||
regvar(ap) register arg_p ap; {
|
||||
register reg_p rp;
|
||||
register i;
|
||||
void regvar(arg_p ap)
|
||||
{
|
||||
reg_p rp;
|
||||
int i;
|
||||
|
||||
rp = newreg();
|
||||
i=0;
|
||||
@@ -46,7 +47,8 @@ regvar(ap) register arg_p ap; {
|
||||
curpro.freg = rp;
|
||||
}
|
||||
|
||||
inreg(off) offset off; {
|
||||
int inreg(offset off)
|
||||
{
|
||||
register reg_p rp;
|
||||
|
||||
for (rp=curpro.freg; rp != (reg_p) 0; rp=rp->r_next)
|
||||
@@ -55,9 +57,10 @@ inreg(off) offset off; {
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
outregs() {
|
||||
register reg_p rp,tp;
|
||||
register i;
|
||||
void outregs()
|
||||
{
|
||||
reg_p rp,tp;
|
||||
int i;
|
||||
|
||||
for(rp=curpro.freg; rp != (reg_p) 0; rp = tp) {
|
||||
tp = rp->r_next;
|
||||
@@ -79,8 +82,8 @@ outregs() {
|
||||
}
|
||||
|
||||
/* outtes() handles the output of the top elt. messages */
|
||||
outtes() {
|
||||
register num_p *npp, np;
|
||||
void outtes() {
|
||||
num_p *npp, np;
|
||||
|
||||
for (npp=curpro.numhash;npp< &curpro.numhash[NNUMHASH]; npp++) {
|
||||
for (np = *npp; np != (num_p) 0; np=np->n_next) {
|
||||
@@ -96,8 +99,9 @@ outtes() {
|
||||
}
|
||||
}
|
||||
|
||||
incregusage(off) offset off; {
|
||||
register reg_p rp;
|
||||
void incregusage(offset off)
|
||||
{
|
||||
reg_p rp;
|
||||
|
||||
#ifndef GLOBAL_OPT
|
||||
/* If we're optimizing the output of the global optimizer
|
||||
|
||||
@@ -24,6 +24,9 @@ static char rcsid[] = "$Id$";
|
||||
extern char *pop_push[];
|
||||
extern char flow_tab[];
|
||||
|
||||
void assign_label(num_p label);
|
||||
void do_inst_label(line_p lnp);
|
||||
|
||||
#define NON_CONTINUABLE(i) (flow_tab[i]&JUMP)
|
||||
#define ISABRANCH(i) (flow_tab[i]&HASLABEL)
|
||||
#define ISCONDBRANCH(i) (flow_tab[i]&CONDBRA)
|
||||
@@ -39,22 +42,22 @@ extern char flow_tab[];
|
||||
int state;
|
||||
static int stacktop = 0;
|
||||
|
||||
init_state()
|
||||
void init_state()
|
||||
{
|
||||
stacktop = 0;
|
||||
state = KNOWN;
|
||||
}
|
||||
|
||||
tes_pseudos()
|
||||
void tes_pseudos()
|
||||
{
|
||||
register line_p lp;
|
||||
line_p lp;
|
||||
|
||||
for (lp = pseudos; lp != (line_p)0; lp = lp->l_next) {
|
||||
switch(INSTR(lp)) {
|
||||
case ps_con:
|
||||
case ps_rom:
|
||||
if (lp->l_optyp == OPLIST) {
|
||||
register arg_p ap = lp->l_a.la_arg;
|
||||
arg_p ap = lp->l_a.la_arg;
|
||||
|
||||
while (ap != (arg_p) 0) {
|
||||
if (ap->a_typ == ARGNUM) {
|
||||
@@ -68,12 +71,11 @@ tes_pseudos()
|
||||
}
|
||||
}
|
||||
|
||||
tes_instr(lnp, x, y)
|
||||
line_p lnp, x, y;
|
||||
void tes_instr(line_p lnp, line_p x, line_p y)
|
||||
{
|
||||
char *s;
|
||||
register instr = INSTR(lnp);
|
||||
register int arg, argdef;
|
||||
int instr = INSTR(lnp);
|
||||
int arg, argdef;
|
||||
int neg = 0;
|
||||
|
||||
if (instr == op_lab) {
|
||||
@@ -155,8 +157,7 @@ line_p lnp, x, y;
|
||||
}
|
||||
}
|
||||
|
||||
assign_label(label)
|
||||
register num_p label;
|
||||
void assign_label(num_p label)
|
||||
{
|
||||
if (label->n_flags & NUMSET) {
|
||||
if (state == NOTREACHED || stacktop > label->n_size) {
|
||||
@@ -170,8 +171,7 @@ register num_p label;
|
||||
}
|
||||
}
|
||||
|
||||
do_inst_label(lnp) /* (re-)install a label */
|
||||
line_p lnp;
|
||||
void do_inst_label(line_p lnp) /* (re-)install a label */
|
||||
{
|
||||
num_p label = lnp->l_a.la_np->n_repl;
|
||||
int instr = INSTR(lnp);
|
||||
|
||||
Reference in New Issue
Block a user