some changes that may make ncg a tiny bit less inefficient

This commit is contained in:
ceriel 1991-01-10 18:39:36 +00:00
parent 32eddf7846
commit f572b1fb35
6 changed files with 209 additions and 184 deletions

View file

@ -502,7 +502,7 @@ normalfailed: if (stackpad!=tokpatlen) {
DEBUG(dokill ? "KILLREG" : "RREMOVE");
getint(nodeno,codep);
result=compute(&enodes[nodeno]);
compute(&enodes[nodeno], &result);
if (result.e_typ!=EV_REG)
break;
if ( in_stack(result.e_v.e_reg) ) BROKE() ; /* Check aside-stack */
@ -622,9 +622,8 @@ normalfailed: if (stackpad!=tokpatlen) {
* known contents is available (the others might still
* be useful).
*/
instance(0,&token2);
for (i=0;i<npos;i++)
if (eqtoken(&machregs[pos[i]].r_contents,&token2)) {
if (machregs[pos[i]].r_contents.t_token == 0) {
pos2[exactmatch++] = pos[i];
}
}
@ -769,7 +768,7 @@ normalfailed: if (stackpad!=tokpatlen) {
DEBUG("ERASE");
getint(nodeno,codep);
result=compute(&enodes[nodeno]);
compute(&enodes[nodeno], &result);
assert(result.e_typ!=EV_INT && result.e_typ!=EV_ADDR);
if (result.e_typ==EV_REG)
erasereg(result.e_v.e_reg);
@ -829,7 +828,7 @@ normalfailed: if (stackpad!=tokpatlen) {
getint(eminstr,codep);
getint(nodeno,codep);
emp[i].em_instr = eminstr;
result[i] = compute(&enodes[nodeno]);
compute(&enodes[nodeno], &result[i]);
}
for (i=0;i<emrepllen;i++) {
switch(result[i].e_typ) {

View file

@ -117,28 +117,27 @@ string tostring(n) register word n; {
return(mystrcpy(buf));
}
result_t undefres= {EV_UNDEF};
result_t compute(node) register node_p node; {
result_t leaf1,leaf2,result;
compute(node, presult) register node_p node; register result_t *presult; {
result_t leaf1,leaf2;
register token_p tp;
int desc;
long mask,tmp;
int i,tmpreg;
glosym_p gp;
presult->e_typ = EV_UNDEF;
desc=opdesc[node->ex_operator];
if (desc&LLEAF) {
leaf1 = compute(&enodes[node->ex_lnode]);
compute(&enodes[node->ex_lnode], &leaf1);
if (desc&LDEF && leaf1.e_typ==EV_UNDEF)
return(undefres);
return;
}
if (desc&RLEAF) {
leaf2 = compute(&enodes[node->ex_rnode]);
compute(&enodes[node->ex_rnode], &leaf2);
if (desc&RDEF && leaf2.e_typ==EV_UNDEF)
return(undefres);
return;
}
result.e_typ=EV_INT;
presult->e_typ=EV_INT;
switch(node->ex_operator) {
default: assert(FALSE);
case EX_TOKFIELD:
@ -146,207 +145,214 @@ result_t compute(node) register node_p node; {
if (curtoken) tp = curtoken;
else tp = &fakestack[stackheight-1];
else tp = &fakestack[stackheight-node->ex_lnode];
switch(result.e_typ = tokens[tp->t_token].t_type[node->ex_rnode-1]) {
switch(presult->e_typ = tokens[tp->t_token].t_type[node->ex_rnode-1]) {
default:
assert(FALSE);
case EV_INT:
result.e_v.e_con = tp->t_att[node->ex_rnode-1].aw;
presult->e_v.e_con = tp->t_att[node->ex_rnode-1].aw;
break;
case EV_ADDR:
result.e_v.e_addr = tp->t_att[node->ex_rnode-1].aa;
presult->e_v.e_addr = tp->t_att[node->ex_rnode-1].aa;
break;
case EV_REG:
result.e_v.e_reg = tp->t_att[node->ex_rnode-1].ar;
presult->e_v.e_reg = tp->t_att[node->ex_rnode-1].ar;
break;
}
return(result);
return;
case EX_ARG:
return(dollar[node->ex_lnode-1]);
*presult = dollar[node->ex_lnode-1];
return;
case EX_CON:
result.e_typ = EV_INT;
result.e_v.e_con = ((long) node->ex_rnode << 16) | ((long)node->ex_lnode&0xffff);
return(result);
presult->e_typ = EV_INT;
presult->e_v.e_con = ((long) node->ex_rnode << 16) | ((long)node->ex_lnode&0xffff);
return;
case EX_REG:
result.e_typ = EV_REG;
result.e_v.e_reg = node->ex_lnode;
return(result);
presult->e_typ = EV_REG;
presult->e_v.e_reg = node->ex_lnode;
return;
case EX_ALLREG:
result.e_typ = EV_REG;
result.e_v.e_reg = allreg[node->ex_lnode-1];
presult->e_typ = EV_REG;
presult->e_v.e_reg = allreg[node->ex_lnode-1];
#if MAXMEMBERS!=0
if (node->ex_rnode!=0)
result.e_v.e_reg = machregs[result.e_v.e_reg].
presult->e_v.e_reg = machregs[presult->e_v.e_reg].
r_members[node->ex_rnode-1];
#endif
return(result);
return;
case EX_SAMESIGN:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_typ = EV_INT;
presult->e_typ = EV_INT;
if (leaf1.e_v.e_con>=0)
result.e_v.e_con= leaf2.e_v.e_con>=0;
presult->e_v.e_con= leaf2.e_v.e_con>=0;
else
result.e_v.e_con= leaf2.e_v.e_con<0;
return(result);
presult->e_v.e_con= leaf2.e_v.e_con<0;
return;
case EX_SFIT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
mask = 0xFFFFFFFFL;
for (i=0;i<leaf2.e_v.e_con-1;i++)
mask &= ~(1<<i);
tmp = leaf1.e_v.e_con&mask;
result.e_v.e_con = tmp==0||tmp==mask;
return(result);
presult->e_v.e_con = tmp==0||tmp==mask;
return;
case EX_UFIT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
mask = 0xFFFFFFFFL;
for (i=0;i<leaf2.e_v.e_con;i++)
mask &= ~(1<<i);
result.e_v.e_con = (leaf1.e_v.e_con&mask)==0;
return(result);
presult->e_v.e_con = (leaf1.e_v.e_con&mask)==0;
return;
case EX_ROM:
assert(node->ex_rnode>=0 &&node->ex_rnode<MAXROM);
leaf2=dollar[node->ex_lnode];
presult->e_typ = EV_UNDEF;
if (leaf2.e_typ != EV_ADDR)
return(undefres);
return;
if (leaf2.e_v.e_addr.ea_off!=0)
return(undefres);
return;
gp = lookglo(leaf2.e_v.e_addr.ea_str);
if (gp == (glosym_p) 0)
return(undefres);
return;
if ((gp->gl_rom[MAXROM]&(1<<node->ex_rnode))==0)
return(undefres);
result.e_v.e_con = gp->gl_rom[node->ex_rnode];
return(result);
return;
presult->e_typ = EV_INT;
presult->e_v.e_con = gp->gl_rom[node->ex_rnode];
return;
case EX_ISROM:
leaf2=dollar[node->ex_lnode];
if (leaf2.e_typ != EV_ADDR)
result.e_v.e_con = 0;
presult->e_v.e_con = 0;
else
result.e_v.e_con = lookglo(leaf2.e_v.e_addr.ea_str) != 0;
return(result);
presult->e_v.e_con = lookglo(leaf2.e_v.e_addr.ea_str) != 0;
return;
case EX_LOWW:
result.e_v.e_con = saveemp[node->ex_lnode].em_u.em_loper&0xFFFF;
return(result);
presult->e_v.e_con = saveemp[node->ex_lnode].em_u.em_loper&0xFFFF;
return;
case EX_HIGHW:
result.e_v.e_con = saveemp[node->ex_lnode].em_u.em_loper>>16;
return(result);
presult->e_v.e_con = saveemp[node->ex_lnode].em_u.em_loper>>16;
return;
case EX_NCPEQ:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con==leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con==leaf2.e_v.e_con;
return;
case EX_SCPEQ:
assert(leaf1.e_typ == EV_ADDR && leaf2.e_typ == EV_ADDR);
result.e_v.e_con =
presult->e_v.e_con =
(strcmp(leaf1.e_v.e_addr.ea_str,leaf2.e_v.e_addr.ea_str)==0 &&
leaf1.e_v.e_addr.ea_off==leaf2.e_v.e_addr.ea_off);
return(result);
return;
case EX_RCPEQ:
assert(leaf1.e_typ == EV_REG && leaf2.e_typ == EV_REG);
result.e_v.e_con = leaf1.e_v.e_reg==leaf2.e_v.e_reg;
return(result);
presult->e_v.e_con = leaf1.e_v.e_reg==leaf2.e_v.e_reg;
return;
case EX_NCPNE:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con!=leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con!=leaf2.e_v.e_con;
return;
case EX_SCPNE:
assert(leaf1.e_typ == EV_ADDR && leaf2.e_typ == EV_ADDR);
result.e_v.e_con =
presult->e_v.e_con =
!(strcmp(leaf1.e_v.e_addr.ea_str,leaf2.e_v.e_addr.ea_str)==0 &&
leaf1.e_v.e_addr.ea_off==leaf2.e_v.e_addr.ea_off);
return(result);
return;
case EX_RCPNE:
assert(leaf1.e_typ == EV_REG && leaf2.e_typ == EV_REG);
result.e_v.e_con = leaf1.e_v.e_reg!=leaf2.e_v.e_reg;
return(result);
presult->e_v.e_con = leaf1.e_v.e_reg!=leaf2.e_v.e_reg;
return;
case EX_NCPGT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con>leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con>leaf2.e_v.e_con;
return;
case EX_NCPGE:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con>=leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con>=leaf2.e_v.e_con;
return;
case EX_NCPLT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con<leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con<leaf2.e_v.e_con;
return;
case EX_NCPLE:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con<=leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con<=leaf2.e_v.e_con;
return;
case EX_OR2:
assert(leaf1.e_typ == EV_INT);
if (leaf1.e_v.e_con==0)
return(compute(&enodes[node->ex_rnode]));
return(leaf1);
if (leaf1.e_v.e_con==0) {
compute(&enodes[node->ex_rnode], presult);
}
else *presult = leaf1;
return;
case EX_AND2:
assert(leaf1.e_typ == EV_INT);
if (leaf1.e_v.e_con!=0)
return(compute(&enodes[node->ex_rnode]));
return(leaf1);
if (leaf1.e_v.e_con!=0) {
compute(&enodes[node->ex_rnode], presult);
}
else *presult = leaf1;
return;
case EX_PLUS:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con=leaf1.e_v.e_con+leaf2.e_v.e_con;
return(result);
presult->e_v.e_con=leaf1.e_v.e_con+leaf2.e_v.e_con;
return;
case EX_CAT:
assert(leaf1.e_typ == EV_ADDR && leaf2.e_typ == EV_ADDR);
result.e_typ = EV_ADDR;
result.e_v.e_addr.ea_str = mycat(leaf1.e_v.e_addr.ea_str,leaf2.e_v.e_addr.ea_str);
result.e_v.e_addr.ea_off = leaf1.e_v.e_addr.ea_off+leaf2.e_v.e_addr.ea_off;
return(result);
presult->e_typ = EV_ADDR;
presult->e_v.e_addr.ea_str = mycat(leaf1.e_v.e_addr.ea_str,leaf2.e_v.e_addr.ea_str);
presult->e_v.e_addr.ea_off = leaf1.e_v.e_addr.ea_off+leaf2.e_v.e_addr.ea_off;
return;
case EX_MINUS:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con - leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con - leaf2.e_v.e_con;
return;
case EX_OR:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con | leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con | leaf2.e_v.e_con;
return;
case EX_XOR:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con ^ leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con ^ leaf2.e_v.e_con;
return;
case EX_AND:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con & leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con & leaf2.e_v.e_con;
return;
case EX_TIMES:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con * leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con * leaf2.e_v.e_con;
return;
case EX_DIVIDE:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con / leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con / leaf2.e_v.e_con;
return;
case EX_MOD:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con % leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con % leaf2.e_v.e_con;
return;
case EX_LSHIFT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con << leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con << leaf2.e_v.e_con;
return;
case EX_RSHIFT:
assert(leaf1.e_typ == EV_INT && leaf2.e_typ == EV_INT);
result.e_v.e_con = leaf1.e_v.e_con >> leaf2.e_v.e_con;
return(result);
presult->e_v.e_con = leaf1.e_v.e_con >> leaf2.e_v.e_con;
return;
case EX_NOT:
assert(leaf1.e_typ == EV_INT);
result.e_v.e_con = !leaf1.e_v.e_con;
return(result);
presult->e_v.e_con = !leaf1.e_v.e_con;
return;
case EX_COMP:
assert(leaf1.e_typ == EV_INT);
result.e_v.e_con = ~leaf1.e_v.e_con;
return(result);
presult->e_v.e_con = ~leaf1.e_v.e_con;
return;
case EX_STRING:
result.e_typ = EV_ADDR;
result.e_v.e_addr.ea_str = codestrings[node->ex_lnode];
result.e_v.e_addr.ea_off = 0;
return(result);
presult->e_typ = EV_ADDR;
presult->e_v.e_addr.ea_str = codestrings[node->ex_lnode];
presult->e_v.e_addr.ea_off = 0;
return;
case EX_DEFINED:
result.e_v.e_con=leaf1.e_typ!=EV_UNDEF;
return(result);
presult->e_v.e_con=leaf1.e_typ!=EV_UNDEF;
return;
case EX_SUBREG:
result.e_typ = EV_REG;
presult->e_typ = EV_REG;
if (node->ex_lnode==0)
if (curtoken) tp = curtoken;
else tp = &fakestack[stackheight-1];
@ -357,52 +363,54 @@ result_t compute(node) register node_p node; {
if (node->ex_rnode)
tmpreg=machregs[tmpreg].r_members[node->ex_rnode-1];
#endif
result.e_v.e_reg=tmpreg;
return(result);
presult->e_v.e_reg=tmpreg;
return;
case EX_TOSTRING:
assert(leaf1.e_typ == EV_INT);
result.e_typ = EV_ADDR;
result.e_v.e_addr.ea_str = "";
result.e_v.e_addr.ea_off = leaf1.e_v.e_con;
return(result);
presult->e_typ = EV_ADDR;
presult->e_v.e_addr.ea_str = "";
presult->e_v.e_addr.ea_off = leaf1.e_v.e_con;
return;
#ifdef REGVARS
case EX_INREG:
assert(leaf1.e_typ == EV_INT);
result.e_v.e_con = isregtyp((long) leaf1.e_v.e_con);
return(result);
presult->e_v.e_con = isregtyp((long) leaf1.e_v.e_con);
return;
case EX_REGVAR:
assert(leaf1.e_typ == EV_INT);
i = isregvar((long) leaf1.e_v.e_con);
if (i<=0)
return(undefres);
result.e_typ = EV_REG;
result.e_v.e_reg=i;
return(result);
if (i<=0) {
presult->e_typ = EV_UNDEF;
return;
}
presult->e_typ = EV_REG;
presult->e_v.e_reg=i;
return;
#endif
case EX_UMINUS:
assert(leaf1.e_typ == EV_INT);
result.e_v.e_con = -leaf1.e_v.e_con;
return(result);
presult->e_v.e_con = -leaf1.e_v.e_con;
return;
#ifdef USE_TES
case EX_TOPELTSIZE: /* Hans, new */
{ register label_p lbl;
lbl = get_label(saveemp[node->ex_lnode].em_u.em_ioper);
if (lbl != (label_p)0) {
result.e_v.e_con = lbl->lb_height;
presult->e_v.e_con = lbl->lb_height;
} else {
result.e_v.e_con = 0;
presult->e_v.e_con = 0;
}
return(result);
return;
}
case EX_FALLTHROUGH: /* Hans, new */
{ register label_p lbl;
lbl = get_label(saveemp[node->ex_lnode].em_u.em_ioper);
if (lbl != (label_p)0) {
result.e_v.e_con = lbl->lb_fallthrough;
} else result.e_v.e_con = 0;
return(result);
presult->e_v.e_con = lbl->lb_fallthrough;
} else presult->e_v.e_con = 0;
return;
}
#endif
}

View file

@ -54,7 +54,7 @@ byte *trypat(bp,len) register byte *bp; {
struct emline *svp = saveemp;
saveemp = emp;
result = compute(&enodes[i]);
compute(&enodes[i], &result);
if (result.e_typ != EV_INT || result.e_v.e_con == 0) {
saveemp = svp;
return(0);

View file

@ -21,7 +21,7 @@ static char rcsid[] = "$Header$";
chrefcount(regno,amount,tflag) {
register struct reginfo *rp;
#if MAXMEMBERS != 0
register i;
register i, tmp;
#endif
rp= &machregs[regno];
@ -35,15 +35,15 @@ chrefcount(regno,amount,tflag) {
#if MAXMEMBERS!=0
} else
for (i=0;i<MAXMEMBERS;i++)
if (rp->r_members[i]!=0)
chrefcount(rp->r_members[i],amount,tflag);
if ((tmp = rp->r_members[i])!=0)
chrefcount(tmp,amount,tflag);
#endif
}
getrefcount(regno, tflag) {
register struct reginfo *rp;
#if MAXMEMBERS != 0
register i,maxcount;
register i,maxcount, tmp;
#endif
rp= &machregs[regno];
@ -55,8 +55,10 @@ getrefcount(regno, tflag) {
else {
maxcount=0;
for (i=0;i<MAXMEMBERS;i++)
if (rp->r_members[i]!=0)
maxcount=max(maxcount,getrefcount(rp->r_members[i], tflag));
if ((tmp=rp->r_members[i])!=0) {
tmp = getrefcount(tmp, tflag);
if (tmp > maxcount) maxcount = tmp;
}
return(maxcount);
}
#endif
@ -65,33 +67,13 @@ getrefcount(regno, tflag) {
erasereg(regno) {
register struct reginfo *rp = &machregs[regno];
register int i;
register byte *tdpb;
#if MAXMEMBERS==0
rp->r_contents.t_token = 0;
for (i=0;i<TOKENSIZE;i++)
for (i=TOKENSIZE-1;i>=0;i--)
rp->r_contents.t_att[i].aw = 0;
awayreg(regno);
#else
extern short clashlist[];
register short *sp = &clashlist[rp->r_iclash];
rp->r_contents.t_token = 0;
while (*sp) {
rp = &machregs[*sp];
rp->r_contents.t_token = 0;
for (i=0;i<TOKENSIZE;i++)
rp->r_contents.t_att[i].aw = 0;
awayreg(*sp++);
}
#endif
}
awayreg(regno) {
register struct reginfo *rp;
register byte *tdpb;
register i;
/* Now erase recursively all registers containing
* something using this one
*/
@ -103,7 +85,7 @@ awayreg(regno) {
lines
*/
rp->r_contents.t_token = 0;
for (i=0;i<TOKENSIZE;i++)
for (i=TOKENSIZE-1;i>=0;i--)
rp->r_contents.t_att[i].aw = 0;
}
} else if (rp->r_contents.t_token > 0) {
@ -116,12 +98,55 @@ awayreg(regno) {
lines
*/
rp->r_contents.t_token = 0;
for (i=0;i<TOKENSIZE;i++)
for (i=TOKENSIZE-1;i>=0;i--)
rp->r_contents.t_att[i].aw = 0;
break;
}
}
}
#else
extern short clashlist[];
register short *sp = &clashlist[rp->r_iclash];
rp->r_contents.t_token = 0;
while (*sp) {
rp = &machregs[*sp];
rp->r_contents.t_token = 0;
for (i=TOKENSIZE-1;i>=0;i--)
rp->r_contents.t_att[i].aw = 0;
regno = *sp++;
/* Now erase recursively all registers containing
* something using this one
*/
for (rp=machregs;rp<machregs+NREGS;rp++) {
if (rp->r_contents.t_token == -1) {
if (rp->r_contents.t_att[0].ar == regno) {
/* erasereg(rp-machregs);
replaced by the following three
lines
*/
rp->r_contents.t_token = 0;
for (i=TOKENSIZE-1;i>=0;i--)
rp->r_contents.t_att[i].aw = 0;
}
} else if (rp->r_contents.t_token > 0) {
tdpb= & (tokens[rp->r_contents.t_token].t_type[0]);
for (i=0;i<TOKENSIZE;i++)
if (*tdpb++ == EV_REG &&
rp->r_contents.t_att[i].ar == regno) {
/* erasereg(rp-machregs);
replaced by the following three
lines
*/
rp->r_contents.t_token = 0;
for (i=TOKENSIZE-1;i>=0;i--)
rp->r_contents.t_att[i].aw = 0;
break;
}
}
}
}
#endif
}
cleanregs() {
@ -130,7 +155,7 @@ cleanregs() {
for (rp=machregs;rp<machregs+NREGS;rp++) {
rp->r_contents.t_token = 0;
for (i=0;i<TOKENSIZE;i++)
for (i=TOKENSIZE-1;i>=0;i--)
rp->r_contents.t_att[i].aw = 0;
}
}

View file

@ -19,5 +19,3 @@ struct result {
#define EV_ADDR 3
typedef struct result result_t;
extern result_t compute();

View file

@ -30,7 +30,7 @@ match(tp,tep,optexp) register token_p tp; register set_p tep; {
if (tp->t_token == -1) { /* register frame */
bitno = tp->t_att[0].ar;
if (tep->set_val[bitno>>4]&(1<<(bitno&017)))
if (tep->set_val[0]&1 || getrefcount(tp->t_att[0].ar, FALSE)<=1)
if (tep->set_val[0]&1 || getrefcount(bitno, FALSE)<=1)
goto oklabel;
return(0);
} else { /* token frame */
@ -43,7 +43,7 @@ match(tp,tep,optexp) register token_p tp; register set_p tep; {
return(1);
ct=curtoken;
curtoken=tp;
result=compute(&enodes[optexp]);
compute(&enodes[optexp], &result);
curtoken=ct;
return(result.e_v.e_con);
}
@ -60,7 +60,7 @@ instance(instno,token) register token_p token; {
if (instno==0) {
token->t_token = 0;
for(i=0;i<TOKENSIZE;i++)
for (i=TOKENSIZE-1;i>=0;i--)
token->t_att[i].aw=0;
return;
}
@ -113,12 +113,12 @@ instance(instno,token) register token_p token; {
#ifdef REGVARS
case IN_S_DESCR:
case IN_D_DESCR:
result=compute(&enodes[inp->in_info[1]]);
compute(&enodes[inp->in_info[1]], &result);
assert(result.e_typ==EV_INT);
if ((regno=isregvar(result.e_v.e_con)) > 0) {
token->t_token = -1;
token->t_att[0].ar = regno;
for(i=1;i<TOKENSIZE;i++)
for (i=TOKENSIZE-1;i>0;i--)
token->t_att[i].aw = 0;
return;
}
@ -131,7 +131,7 @@ instance(instno,token) register token_p token; {
assert(tokens[token->t_token].t_type[i]==0);
token->t_att[i].aw=0;
} else {
result=compute(&enodes[inp->in_info[i+1]]);
compute(&enodes[inp->in_info[i+1]], &result);
assert(tokens[token->t_token].t_type[i]==result.e_typ);
if (result.e_typ==EV_INT)
token->t_att[i].aw=result.e_v.e_con;
@ -199,13 +199,13 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
{ token_p ct = curtoken;
curtoken = tp;
result=compute(&enodes[inp->in_info[1]]);
compute(&enodes[inp->in_info[1]], &result);
curtoken = ct;
assert(result.e_typ==EV_INT);
if ((regno=isregvar(result.e_v.e_con)) > 0) {
token->t_token = -1;
token->t_att[0].ar = regno;
for(i=1;i<TOKENSIZE;i++)
for (i=TOKENSIZE-1;i>0;i--)
token->t_att[i].aw = 0;
return;
}
@ -224,7 +224,7 @@ cinstance(instno,token,tp,regno) register token_p token,tp; {
token_p ct = curtoken;
curtoken = tp;
result=compute(&enodes[inp->in_info[i+1]]);
compute(&enodes[inp->in_info[i+1]], &result);
curtoken = ct;
assert(tokens[token->t_token].t_type[i]==result.e_typ);
if (result.e_typ==EV_INT)
@ -419,14 +419,14 @@ instsize(tinstno,tp) token_p tp; {
tref(tp,amount) register token_p tp; {
register i;
register tkdef_p tdp;
register byte *tdpb;
if (tp->t_token==-1)
chrefcount(tp->t_att[0].ar,amount,FALSE);
else {
tdp= &tokens[tp->t_token];
tdpb= &tokens[tp->t_token].t_type[0];
for(i=0;i<TOKENSIZE;i++)
if (tdp->t_type[i]==EV_REG)
if (*tdpb++==EV_REG)
chrefcount(tp->t_att[i].ar,amount,FALSE);
}
}
@ -707,8 +707,3 @@ badassertion(asstr,file,line) char *asstr, *file; {
fatal("\"%s\", line %d:Assertion \"%s\" failed",file,line,asstr);
}
#endif
max(a,b) {
return(a>b ? a : b);
}