From fc2f8b7a6ebd64615c68380fa317d40301a99c81 Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Sat, 11 Feb 2017 13:13:07 +1100 Subject: [PATCH] Fix over-enthusiastic uniqification (adding 0|1 to symbols that didn't need it) --- c0.h | 8 +- c00.c | 82 ++++---- c01.c | 94 ++++----- c02.c | 36 ++-- c03.c | 2 +- c04.c | 34 +-- c05.c | 4 +- c1.h | 32 +-- c10.c | 446 +++++++++++++++++++-------------------- c11.c | 178 ++++++++-------- c12.c | 578 +++++++++++++++++++++++++-------------------------- c13.c | 12 +- unify01.sed | 9 +- uniqify0.sed | 42 ++-- uniqify1.sed | 46 ++-- 15 files changed, 806 insertions(+), 797 deletions(-) diff --git a/c0.h b/c0.h index ab8d50a..2fe1536 100644 --- a/c0.h +++ b/c0.h @@ -65,7 +65,7 @@ extern char ctab[]; extern char symbuf[MAXCPS+2]; extern struct nmlist *hshtab[HSHSIZ]; extern int kwhash[(HSHSIZ+LNBPW-1)/LNBPW]; -extern union tree **cp0; +extern union tree **cp; extern int isn0; extern struct swtab swtab[SWSIZ]; extern int unscflg; @@ -106,7 +106,7 @@ extern FILE *sbufp; #endif extern int regvar; extern int bitoffs; -extern struct tnode funcblk0; +extern struct tnode funcblk; extern char cvntab[]; extern char numbuf[64]; extern struct nmlist **memlist; @@ -201,8 +201,8 @@ void putstr __P((int lab, register int max)); void cntstr __P((void)); int getcc __P((void)); int mapch __P((int ac)); -union tree *tree0 __P((/*int eflag*/)); -union tree *xprtype0 __P((void)); +union tree *tree __P((/*int eflag*/)); +union tree *xprtype __P((void)); char *copnum __P((int len)); /* c01.c */ diff --git a/c00.c b/c00.c index 20f0ea2..8f4e0f0 100644 --- a/c00.c +++ b/c00.c @@ -18,7 +18,7 @@ int isn0 = 1; int peeksym = -1; int line = 1; -struct tnode funcblk0 = { NAME }; +struct tnode funcblk = { NAME }; struct kwtab kwtab[] = { {"int", INT}, @@ -55,7 +55,7 @@ struct kwtab kwtab[] = { }; union tree *cmst[CMSIZ]; -union tree **cp0 = cmst; +union tree **cp = cmst; int Wflag; /* print warning messages */ #if 0 @@ -622,13 +622,13 @@ loop: } /* - * Read an expression and return a pointer to its tree0. + * Read an expression and return a pointer to its tree. * It's the classical bottom-up, priority-driven scheme. * The initflg prevents the parse from going past * "," or ":" because those delimiters are special * in initializer (and some other) expressions. */ -union tree *tree0(/*eflag*/) /*int eflag;*/ { +union tree *tree(/*eflag*/) /*int eflag;*/ { int *op, opst[SSIZE], *pp, prst[SSIZE]; register int andflg, o; register struct nmlist *cs; @@ -651,7 +651,7 @@ advanc: if (cs->hclass==TYPEDEF) goto atype; if (cs->hclass==ENUMCON) { - *cp0++ = cblock(cs->hoffset); + *cp++ = cblock(cs->hoffset); goto tand; } if (cs->hclass==0 && cs->htype==0) @@ -664,29 +664,29 @@ advanc: error0("%s undefined; func. %s", cs->name, funcsym ? funcsym->name : "(none)"); } - *cp0++ = nblock(cs); + *cp++ = nblock(cs); goto tand; case FCON: - /* *cp0++ = fblock(DOUBLE, copnum(cval));*/ - *cp0 = (union tree *)Tblock(sizeof(struct ftconst)); - (*cp0)->f.op = FCON; - (*cp0)->f.type = DOUBLE; - (*cp0)->f.value = isn1++; - (*cp0)->f.fvalue = fcval; - cp0++; + /* *cp++ = fblock(DOUBLE, copnum(cval));*/ + *cp = (union tree *)Tblock(sizeof(struct ftconst)); + (*cp)->f.op = FCON; + (*cp)->f.type = DOUBLE; + (*cp)->f.value = isn1++; + (*cp)->f.fvalue = fcval; + cp++; goto tand; case LCON: - *cp0 = (union tree *)Tblock(sizeof(struct lconst)); - (*cp0)->l.op = LCON; - (*cp0)->l.type = LONG; - (*cp0)->l.lvalue = lcval; - cp0++; + *cp = (union tree *)Tblock(sizeof(struct lconst)); + (*cp)->l.op = LCON; + (*cp)->l.type = LONG; + (*cp)->l.lvalue = lcval; + cp++; goto tand; case CON: - *cp0++ = cblock(cval); + *cp++ = cblock(cval); goto tand; /* fake a static char array */ @@ -723,25 +723,25 @@ advanc: cs->hoffset = cval; #if 1 /* one-pass version */ /* really should change this to use nblock and fill in nmlist above better */ - *cp0 = (union tree *)Tblock(sizeof(struct tname)); - (*cp0)->n.op = NAME; - (*cp0)->n.type = unscflg? ARRAY+UNCHAR:ARRAY+CHAR; - (*cp0)->n.subsp = &nchstr; - (*cp0)->n.strp = (union str *)NULL; - (*cp0)->n.tr1 = (union tree *)cs; - (*cp0)->n.class = STATIC; - (*cp0)->n.regno = 0; - (*cp0)->n.offset = 0; - (*cp0)->n.nloc = cval; - cp0++; + *cp = (union tree *)Tblock(sizeof(struct tname)); + (*cp)->n.op = NAME; + (*cp)->n.type = unscflg? ARRAY+UNCHAR:ARRAY+CHAR; + (*cp)->n.subsp = &nchstr; + (*cp)->n.strp = (union str *)NULL; + (*cp)->n.tr1 = (union tree *)cs; + (*cp)->n.class = STATIC; + (*cp)->n.regno = 0; + (*cp)->n.offset = 0; + (*cp)->n.nloc = cval; + cp++; #else - *cp0++ = block(NAME, unscflg? ARRAY+UNCHAR:ARRAY+CHAR, &nchstr, + *cp++ = block(NAME, unscflg? ARRAY+UNCHAR:ARRAY+CHAR, &nchstr, (union str *)NULL, (union tree *)cs, TNULL); #endif - /*printf("string %p\n", cp0[-1]);*/ + /*printf("string %p\n", cp[-1]);*/ tand: - if(cp0>=cmst+CMSIZ) { + if(cp>=cmst+CMSIZ) { error0("Expression overflow"); exit(1); } @@ -755,7 +755,7 @@ advanc: if (*op != LPARN || andflg) goto syntax; peeksym = o; - *cp0++ = xprtype0(); + *cp++ = xprtype(); if ((o=symbol()) != RPARN) goto syntax; o = CAST; @@ -882,7 +882,7 @@ opon1: build(0); /* flush conversions */ /*if (eflag) endtree(svtree);*/ - return(*--cp0); + return(*--cp); case COMMA: if (*op != CALL) @@ -896,7 +896,7 @@ opon1: goto advanc; case MCALL: - *cp0++ = block(NULLOP0, INT, (int *)NULL, + *cp++ = block(NULLOP0, INT, (int *)NULL, (union str *)NULL, TNULL, TNULL); os = CALL; break; @@ -905,7 +905,7 @@ opon1: case INCAFT: case DECBEF: case DECAFT: - *cp0++ = cblock(1); + *cp++ = cblock(1); break; case LPARN: @@ -930,13 +930,13 @@ syntax: return((union tree *) &garbage); } -union tree *xprtype0() { +union tree *xprtype() { struct nmlist typer, absname; int sc; register union tree **scp; - scp = cp0; - sc = DEFXTRN; /* will cause error0 if class mentioned */ + scp = cp; + sc = DEFXTRN; /* will cause error if class mentioned */ getkeywords(&sc, &typer); absname.hclass = 0; absname.hblklev = blklev; @@ -944,7 +944,7 @@ union tree *xprtype0() { absname.hstrp = NULL; absname.htype = 0; decl1(sc, &typer, 0, &absname); - cp0 = scp; + cp = scp; return(block(ETYPE, absname.htype, absname.hsubsp, absname.hstrp, TNULL, TNULL)); } diff --git a/c01.c b/c01.c index 1e1059f..829be84 100644 --- a/c01.c +++ b/c01.c @@ -15,7 +15,7 @@ #include "c0.h" /* - * Called from tree0, this routine takes the top 1, 2, or 3 + * Called from tree, this routine takes the top 1, 2, or 3 * operands on the expression stack, makes a new node with * the operator op, and puts it on the stack. * Essentially all the work is in inserting @@ -37,18 +37,18 @@ void build(op) int op; { dope = opdope0[op]; t2 = INT; if ((dope&BINARY)!=0) { - p2 = chkfun(disarray(*--cp0)); + p2 = chkfun(disarray(*--cp)); if (p2) t2 = p2->t.type; } - p1 = *--cp0; + p1 = *--cp; /* * sizeof gets turned into a number here. */ if (op==SIZEOF) { p1 = cblock(length(p1)); p1->c.type = UNSIGN; - *cp0++ = p1; + *cp++ = p1; return; } if (op!=AMPER) { @@ -73,11 +73,11 @@ void build(op) int op; { if ((t1&XTYPE)==FUNC || (t1&XTYPE)==ARRAY) error0("Disallowed conversion"); if (p1->t.type==UNCHAR) { - *cp0++ = block(ETYPE, UNSIGN, (int *)NULL, (union str *)NULL, + *cp++ = block(ETYPE, UNSIGN, (int *)NULL, (union str *)NULL, TNULL, TNULL); - *cp0++ = p2; + *cp++ = p2; build(CAST); - *cp0++ = cblock(0377); + *cp++ = cblock(0377); build(AND); return; } @@ -88,7 +88,7 @@ void build(op) int op; { /* end of expression */ case 0: - *cp0++ = p1; + *cp++ = p1; return; /* no-conversion operators */ @@ -108,13 +108,13 @@ void build(op) int op; { * case COMMA: */ case SEQNC: - *cp0++ = block(op, t2, p2->t.subsp, p2->t.strp, p1, p2); + *cp++ = block(op, t2, p2->t.subsp, p2->t.strp, p1, p2); return; case COMMA: case LOGAND: case LOGOR: - *cp0++ = block(op, t, p2->t.subsp, p2->t.strp, p1, p2); + *cp++ = block(op, t, p2->t.subsp, p2->t.strp, p1, p2); return; case EXCLA: @@ -136,26 +136,26 @@ void build(op) int op; { * that the new notation is actually more consistent * with the rest of C ... */ - *cp0++ = p1; + *cp++ = p1; build(STAR); - *cp0++ = p2; + *cp++ = p2; build(CALL); return; } if ((t1&XTYPE) != FUNC) error0("Call of non-function"); - *cp0++ = block(CALL,decref0(t1),p1->t.subsp,p1->t.strp,p1,p2); + *cp++ = block(CALL,decref0(t1),p1->t.subsp,p1->t.strp,p1,p2); return; case STAR: if ((t1&XTYPE) == FUNC) error0("Illegal indirection"); - *cp0++ = block(STAR, decref0(t1), p1->t.subsp, p1->t.strp, p1, TNULL); + *cp++ = block(STAR, decref0(t1), p1->t.subsp, p1->t.strp, p1, TNULL); return; case AMPER: if (p1->t.op==NAME || p1->t.op==STAR) { - *cp0++ = block(op,incref0(p1->t.type),p1->t.subsp,p1->t.strp,p1,TNULL); + *cp++ = block(op,incref0(p1->t.type),p1->t.subsp,p1->t.strp,p1,TNULL); return; } error0("Illegal lvalue"); @@ -169,9 +169,9 @@ void build(op) int op; { t1 = incref0(t1); setype(p1, t1, p1); } else { - *cp0++ = p1; + *cp++ = p1; build(AMPER); - p1 = *--cp0; + p1 = *--cp; } /* @@ -182,7 +182,7 @@ void build(op) int op; { case ARROW: if (p2->t.op!=NAME || ((struct nmlist *)p2->t.tr1)->hclass!=MOS) { error0("Illegal structure ref"); - *cp0++ = p1; + *cp++ = p1; return; } structident(p1, p2); @@ -192,16 +192,16 @@ void build(op) int op; { t = incref0(t2); chkw(p1, -1); setype(p1, t, p2); - *cp0++ = block(PLUS, t, p2->t.subsp, p2->t.strp, + *cp++ = block(PLUS, t, p2->t.subsp, p2->t.strp, p1, cblock(((struct nmlist *)p2->t.tr1)->hoffset)); build(STAR); if (((struct nmlist *)p2->t.tr1)->hflag&FFIELD) #if 1 - cp0[-1] = block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, - cp0[-1], (union tree *)((struct nmlist *)p2->t.tr1)->hstrp); + cp[-1] = block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, + cp[-1], (union tree *)((struct nmlist *)p2->t.tr1)->hstrp); #else - *cp0++ = block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, - *--cp0, (union tree *)((struct nmlist *)p2->t.tr1)->hstrp); + *cp++ = block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, + *--cp, (union tree *)((struct nmlist *)p2->t.tr1)->hstrp); #endif return; } @@ -221,7 +221,7 @@ void build(op) int op; { else if (op==FTOI) t1 = INT; if (!fold(op, p1, (union tree *)NULL)) - *cp0++ = block(op, t1, p1->t.subsp, p1->t.strp, p1,TNULL); + *cp++ = block(op, t1, p1->t.subsp, p1->t.strp, p1,TNULL); return; } cvn = 0; @@ -371,18 +371,18 @@ void build(op) int op; { } if (t==INT && p1->t.type==CHAR) p2 = block(ITOC, INT, (int *)NULL, (union str *)NULL, p2, TNULL); - *cp0++ = p2; + *cp++ = p2; return; } if (pcvn) t2 = plength(p1->t.tr1); if (fold(op, p1, p2)==0) { p3 = leftc?p2:p1; - *cp0++ = block(op, t, p3->t.subsp, p3->t.strp, p1, p2); + *cp++ = block(op, t, p3->t.subsp, p3->t.strp, p1, p2); } if (pcvn) { - p1 = *--cp0; - *cp0++ = convert(p1, 0, PTI, t2); + p1 = *--cp; + *cp++ = convert(p1, 0, PTI, t2); } } @@ -436,7 +436,7 @@ union tree *convert(p, t, cvn, len) union tree *p; int t; int cvn; int len; { } /* - * Traverse an expression tree0, adjust things + * Traverse an expression tree, adjust things * so the types of things in it are consistent * with the view that its top node has * type at. @@ -483,10 +483,10 @@ union tree *disarray(p) register union tree *p; { || p->t.op==ETYPE) return(p); p->t.subsp++; - *cp0++ = p; + *cp++ = p; setype(p, decref0(t), p); build(AMPER); - return(*--cp0); + return(*--cp); } /* @@ -532,7 +532,7 @@ int lintyp(t) int t; { } /* - * Report an error0. + * Report an error. */ extern int Wflag; /* Non-zero means do not print warnings */ @@ -575,7 +575,7 @@ void error0(s, va_alist) char *s; va_dcl } /* - * Generate a node in an expression tree0, + * Generate a node in an expression tree, * setting the operator, type, dimen/struct table ptrs, * and the operands. */ @@ -683,7 +683,7 @@ union tree *cblock(v) int v; { /* * Assign a block for use in the - * expression tree0. + * expression tree. */ char *Tblock(n) int n; { register char *p; @@ -691,7 +691,7 @@ char *Tblock(n) int n; { /*fprintf(stderr, "treebase=%p n=%p coremax=%p\n", treebase, n, coremax);*/ p = treebase; if (p==NULL) { - error0("c0 internal error0: Tblock"); + error0("c0 internal error: Tblock"); exit(1); } if ((treebase += n) >= coremax) { @@ -756,7 +756,7 @@ char *Dblock(n) int n; { } /* - * Check that a tree0 can be used as an lvalue. + * Check that a tree can be used as an lvalue. */ void chklval(p) register union tree *p; { if (p->t.op==FSEL) @@ -782,7 +782,7 @@ int fold(op, p1, p2) int op; register union tree *p1; union tree *p2; { if (op==QUEST) { if (p2->t.tr1->t.op==CON && p2->t.tr2->t.op==CON) { p1->c.value = p1->c.value? p2->t.tr1->c.value: p2->t.tr2->c.value; - *cp0++ = p1; + *cp++ = p1; p1->t.type = p2->t.type; return(1); } @@ -924,7 +924,7 @@ int fold(op, p1, p2) int op; register union tree *p1; union tree *p2; { return(0); } p1->c.value = v1; - *cp0++ = p1; + *cp++ = p1; if (unsignf) p1->t.type = UNSIGN; return(1); @@ -938,7 +938,7 @@ int conexp() { register union tree *t; char *st = starttree(); initflg++; - if (t = tree0(/*1*/)) + if (t = tree(/*1*/)) if (t->t.op != CON) error0("Constant required"); initflg--; @@ -955,23 +955,23 @@ void assignop(op, p1, p2) int op; register union tree *p1; register union tree * op += PLUS - ASPLUS; if (p1->t.op==NAME) { - *cp0++ = p1; - *cp0++ = p1; - *cp0++ = p2; + *cp++ = p1; + *cp++ = p1; + *cp++ = p2; build(op); build(ASSIGN); return; } np = gentemp(incref0(p1->t.type)); - *cp0++ = nblock(np); - *cp0++ = p1; + *cp++ = nblock(np); + *cp++ = p1; build(AMPER); build(ASSIGN); - *cp0++ = nblock(np); + *cp++ = nblock(np); build(STAR); - *cp0++ = nblock(np); + *cp++ = nblock(np); build(STAR); - *cp0++ = p2; + *cp++ = p2; build(op); build(ASSIGN); build(SEQNC); diff --git a/c02.c b/c02.c index ef86619..0d91a3d 100644 --- a/c02.c +++ b/c02.c @@ -46,8 +46,8 @@ void extdef() { if ((ds->htype&XTYPE)==FUNC) { if ((peeksym=symbol())==LBRACE || peeksym==KEYW || (peeksym==NAME && csym->hclass==TYPEDEF)) { - funcblk0.type = decref0(ds->htype); - funcblk0.strp = ds->hstrp; + funcblk.type = decref0(ds->htype); + funcblk.strp = ds->hstrp; setinit(ds); outcode("BS", SYMDEF, sclass==EXTERN?ds->name:""); cfunc(); @@ -121,7 +121,7 @@ void cfunc() { /* add STAUTO; overlay bug fix, coupled with section in c11.c */ outcode("BN", SETSTK, -maxauto+STAUTO); branch0(sloc+1); - /*fprintf(stderr, "cb=%p\n", cp0);*/ + /*fprintf(stderr, "cb=%p\n", cp);*/ locbase = cb; } @@ -186,22 +186,22 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; { char *st; initflg++; st = starttree(); - s = tree0(/*0*/); + s = tree(/*0*/); initflg = 0; if (np.hflag&FFIELD) error0("No field initialization"); - *cp0++ = nblock(&np); - *cp0++ = s; + *cp++ = nblock(&np); + *cp++ = s; build(ASSIGN); if (sclass==AUTO||sclass==REG) - rcexpr0(*--cp0); + rcexpr0(*--cp); else if (sclass==ENUMCON) { if (s->t.op!=CON) error0("Illegal enum constant for %s", anp->name); anp->hoffset = s->c.value; } else rcexpr0(block(INIT,np.htype,(int *)NULL, - (union str *)NULL, (*--cp0)->t.tr2, TNULL)); + (union str *)NULL, (*--cp)->t.tr2, TNULL)); endtree(st); } ninit++; @@ -450,7 +450,7 @@ stmt: contlab = o1; if ((o=symbol())==KEYW && cval==WHILE) { char *st = starttree(); - cbranch0(tree0(/*1*/), o3, 1); + cbranch0(tree(/*1*/), o3, 1); endtree(st); label0(brklab); brklab = o2; @@ -551,7 +551,7 @@ stmt: peeksym = o; { char *st = starttree(); - rcexpr0(tree0(/*1*/)); + rcexpr0(tree(/*1*/)); endtree(st); } @@ -577,7 +577,7 @@ int forstmt() { ss = starttree(); if ((o=symbol()) != SEMI) { /* init part */ peeksym = o; - rcexpr0(tree0(/*1*/)); + rcexpr0(tree(/*1*/)); if ((o=symbol()) != SEMI) { endtree(ss); @@ -594,7 +594,7 @@ int forstmt() { if ((o=symbol()) != SEMI) { /* test part */ peeksym = o; /* ss = starttree();*/ - st = tree0(0); + st = tree(0); if ((o=symbol()) != SEMI) { endtree(ss); return(o); @@ -602,7 +602,7 @@ int forstmt() { } if ((o=symbol()) != RPARN) { /* incr part */ peeksym = o; - rcexpr0(tree0(/*1*/)); + rcexpr0(tree(/*1*/)); if ((o=symbol()) != RPARN) { /* if (st)*/ endtree(ss); @@ -634,7 +634,7 @@ union tree *pexpr(/*eflag*/) /*int eflag;*/ { if ((o=symbol())!=LPARN) goto syntax; - t = tree0(/*eflag*/); + t = tree(/*eflag*/); if ((o=symbol())!=RPARN) goto syntax; if (t->t.type==VOID) @@ -706,13 +706,13 @@ void funchead() { pl += rlength((union tree *)cs); if (cs->hclass==AREG && (hreg.hoffset=goodreg(cs))>=0) { st = starttree(); - *cp0++ = (union tree *)&areg; - *cp0++ = nblock(cs); + *cp++ = (union tree *)&areg; + *cp++ = nblock(cs); areg.type = cs->htype; areg.strp = cs->hstrp; cs->hclass = AUTO; build(ASSIGN); - rcexpr0(*--cp0); + rcexpr0(*--cp); cs->hoffset = hreg.hoffset; cs->hclass = REG; endtree(st); @@ -804,7 +804,7 @@ void prste(cs) struct nmlist *cs; { } /* - * In case of error0, skip to the next + * In case of error, skip to the next * statement delimiter. */ void errflush(ao) int ao; { diff --git a/c03.c b/c03.c index 933eb13..68582a5 100644 --- a/c03.c +++ b/c03.c @@ -700,7 +700,7 @@ int align(type, offset, aflen) int type; int offset; int aflen; { } /* - * Complain about syntax error0 in declaration + * Complain about syntax error in declaration */ void decsyn(o) int o; { error0("Declaration syntax"); diff --git a/c04.c b/c04.c index 50959b6..a3f778f 100644 --- a/c04.c +++ b/c04.c @@ -34,8 +34,8 @@ int incref0(t) register int t; { } /* - * Make a tree0 that causes a branch0 to lbl - * if the tree0's value is non-zero together with the cond. + * Make a tree that causes a branch to lbl + * if the tree's value is non-zero together with the cond. */ void cbranch0(t, lbl, cond) union tree *t; int lbl; int cond; { #if 1 /* one-pass version */ @@ -59,7 +59,7 @@ void cbranch0(t, lbl, cond) union tree *t; int lbl; int cond; { } /* - * Write out a tree0. + * Write out a tree. */ void rcexpr0(tp) register union tree *tp; { #if 1 /* one-pass version */ @@ -177,21 +177,21 @@ void treeout(tp, isstruct) register union tree *tp; int isstruct; { #endif /* - * Generate a branch0 + * Generate a branch */ void branch0(lab) int lab; { outcode("BN", BRANCH, lab); } /* - * Generate a label0 + * Generate a label */ void label0(l) int l; { outcode("BN", LABEL, l); } /* - * ap is a tree0 node whose type + * ap is a tree node whose type * is some kind of pointer; return the size of the object * to which the pointer points. */ @@ -208,7 +208,7 @@ int plength(p) register union tree *p; { /* * return the number of bytes in the object - * whose tree0 node is acs. + * whose tree node is acs. */ int length(cs) union tree *cs; { register int t, elsz; @@ -278,7 +278,7 @@ int rlength(cs) union tree *cs; { /* * After an "if (...) goto", look to see if the transfer - * is to a simple label0. + * is to a simple label. */ int simplegoto() { register struct nmlist *csp; @@ -335,7 +335,7 @@ int spnextchar() { */ void chconbrk(l) int l; { if (l==0) - error0("Break/continue error0"); + error0("Break/continue error"); } /* @@ -346,9 +346,9 @@ void dogoto() { register char *st; st = starttree(); - *cp0++ = tree0(/*0*/); + *cp++ = tree(/*0*/); build(STAR); - chkw(np = *--cp0, -1); + chkw(np = *--cp, -1); rcexpr0(block(JUMP, 0, (int *)NULL, (union str *)NULL, np, TNULL)); endtree(st); } @@ -362,19 +362,19 @@ void doret() { register char *st; st = starttree(); - *cp0++ = (union tree *)&funcblk0; - *cp0++ = tree0(/*0*/); + *cp++ = (union tree *)&funcblk; + *cp++ = tree(/*0*/); build(ASSIGN); - cp0[-1] = cp0[-1]->t.tr2; + cp[-1] = cp[-1]->t.tr2; build(RFORCE); - rcexpr0(*--cp0); + rcexpr0(*--cp); endtree(st); } branch0(retlab); } /* - * Write a character on the error0 output. + * Write a character on the error output. */ /* * Coded output: @@ -448,7 +448,7 @@ void outcode(s, va_alist) char *s; va_dcl case '\0': va_end(argp); if (ferror(bufp)) { - error0("Write error0 on temp"); + error0("Write error on temp"); exit(1); } return; diff --git a/c05.c b/c05.c index 0aa8dcb..e393309 100644 --- a/c05.c +++ b/c05.c @@ -9,7 +9,7 @@ * 040-- non-float req. on right * 0100-- is commutative * 0200-- is right, not left-associative - * 0400-- is leaf of tree0 + * 0400-- is leaf of tree * *0XX000-- XX is priority of operator */ int opdope0[] = { @@ -117,7 +117,7 @@ int opdope0[] = { 036001, /* mcall */ 000000, /* goto */ 000000, /* jump cond */ - 000000, /* branch0 cond */ + 000000, /* branch cond */ 000000, /* 105 */ 000000, /* 106 */ 000000, /* 107 */ diff --git a/c1.h b/c1.h index 5f0a526..df49204 100644 --- a/c1.h +++ b/c1.h @@ -122,9 +122,9 @@ extern union tree *ncopy(); extern union tree *getblk(); extern union tree *strfunc(); extern union tree *isconstant(); -extern union tree *tconst1(); +extern union tree *tconst(); extern union tree *hardlongs(); -extern union tree *lconst1(); +extern union tree *lconst(); extern union tree *acommute(); extern union tree *lvfield(); extern union tree *paint(); @@ -155,20 +155,20 @@ struct acl { /* c10.c */ int main __P((int argc, char *argv[])); -struct optab *match __P((union tree *tree1, struct table *table, int nrleft, int nocvt)); +struct optab *match __P((union tree *tree, struct table *table, int nrleft, int nocvt)); int rcexpr1 __P((union tree *atree, struct table *atable, int reg)); -int cexpr __P((register union tree *tree1, struct table *table, int areg)); +int cexpr __P((register union tree *tree, struct table *table, int areg)); int reorder __P((union tree **treep, struct table *table, int reg)); int sreorder __P((union tree **treep, struct table *table, int reg, int recurf)); int delay __P((union tree **treep, struct table *table, int reg)); union tree *sdelay __P((union tree **ap)); union tree *paint __P((register union tree *tp, register int type)); union tree *ncopy __P((register union tree *p)); -int chkleaf __P((register union tree *tree1, struct table *table, int reg)); -int comarg __P((register union tree *tree1, int *flagp)); +int chkleaf __P((register union tree *tree, struct table *table, int reg)); +int comarg __P((register union tree *tree, int *flagp)); union tree *strfunc __P((register union tree *tp)); -void doinit __P((register int type, register union tree *tree1)); -void movreg __P((int r0, int r1, union tree *tree1)); +void doinit __P((register int type, register union tree *tree)); +void movreg __P((int r0, int r1, union tree *tree)); /* c11.c */ int degree __P((register union tree *t)); @@ -185,8 +185,8 @@ int arlength __P((int t)); void pswitch1 __P((struct swtab *afp, struct swtab *alp, int deflab)); void breq __P((int v, int l)); int sort __P((struct swtab *afp, struct swtab *alp)); -int ispow2 __P((register union tree *tree1)); -union tree *pow2 __P((register union tree *tree1)); +int ispow2 __P((register union tree *tree)); +union tree *pow2 __P((register union tree *tree)); void cbranch1 __P((union tree *atree, register int lbl, int cond, register int reg)); void branch1 __P((int lbl, int aop, int c)); void longrel __P((union tree *atree, int lbl, int cond, int reg)); @@ -203,18 +203,18 @@ int decref1 __P((register int t)); int incref1 __P((register int t)); /* c12.c */ -union tree *optim __P((register union tree *tree1)); -union tree *unoptim __P((register union tree *tree1)); +union tree *optim __P((register union tree *tree)); +union tree *unoptim __P((register union tree *tree)); union tree *lvfield __P((register union tree *t)); -union tree *acommute __P((register union tree *tree1)); +union tree *acommute __P((register union tree *tree)); int sideeffects __P((register union tree *tp)); void distrib __P((struct acl *list)); void squash __P((union tree **p, union tree **maxp)); void _const __P((int op, register _INT *vp, _INT v, int type)); -union tree *lconst1 __P((int op, register union tree *lp, register union tree *rp)); -void insert __P((int op, register union tree *tree1, register struct acl *list)); +union tree *lconst __P((int op, register union tree *lp, register union tree *rp)); +void insert __P((int op, register union tree *tree, register struct acl *list)); union tree *tnode1 __P((int op, int type, union tree *tr1, union tree *tr2)); -union tree *tconst1 __P((int val, int type)); +union tree *tconst __P((int val, int type)); union tree *getblk __P((int size)); int islong __P((int t)); union tree *isconstant __P((register union tree *t)); diff --git a/c10.c b/c10.c index 23ab392..a00f8cc 100644 --- a/c10.c +++ b/c10.c @@ -1,7 +1,7 @@ /* * C compiler, part 2 * - * (long)btodb(l) produced 'no code table error1 for op: >>(17) type: 6' + * (long)btodb(l) produced 'no code table error for op: >>(17) type: 6' * allow both long and ulong at line ~341. 1996/6/19 */ @@ -83,14 +83,14 @@ int main(argc, argv) int argc; char *argv[]; { #endif /* - * Given a tree1, a code table, and a + * Given a tree, a code table, and a * count of available registers, find the code table * for the appropriate operator such that the operands * are of the right type and the number of registers * required is not too large. * Return a ptr to the table entry or 0 if none found. */ -struct optab *match(tree1, table, nrleft, nocvt) union tree *tree1; struct table *table; int nrleft; int nocvt; { +struct optab *match(tree, table, nrleft, nocvt) union tree *tree; struct table *table; int nrleft; int nocvt; { #define NOCVL 1 #define NOCVR 2 int op, d1, d2, dope; @@ -98,20 +98,20 @@ struct optab *match(tree1, table, nrleft, nocvt) union tree *tree1; struct table register union tree *p1; register struct optab *opt; - if (tree1==NULL) + if (tree==NULL) return(NULL); if (table==lsptab) table = sptab; - if ((op = tree1->t.op)==0) + if ((op = tree->t.op)==0) return(0); dope = opdope1[op]; if ((dope&LEAF) == 0) - p1 = tree1->t.tr1; + p1 = tree->t.tr1; else - p1 = tree1; + p1 = tree; d1 = dcalc(p1, nrleft); if ((dope&BINARY)!=0) { - p2 = tree1->t.tr2; + p2 = tree->t.tr2; /* * If a subtree starts off with a conversion operator, * try for a match with the conversion eliminated. @@ -121,16 +121,16 @@ struct optab *match(tree1, table, nrleft, nocvt) union tree *tree1; struct table */ if (opdope1[p2->t.op]&CNVRT && (nocvt&NOCVR)==0 && (opdope1[p2->t.tr1->t.op]&CNVRT)==0) { - tree1->t.tr2 = p2->t.tr1; - if (opt = match(tree1, table, nrleft, NOCVL)) + tree->t.tr2 = p2->t.tr1; + if (opt = match(tree, table, nrleft, NOCVL)) return(opt); - tree1->t.tr2 = p2; + tree->t.tr2 = p2; } else if (opdope1[p1->t.op]&CNVRT && (nocvt&NOCVL)==0 && (opdope1[p1->t.tr1->t.op]&CNVRT)==0) { - tree1->t.tr1 = p1->t.tr1; - if (opt = match(tree1, table, nrleft, NOCVR)) + tree->t.tr1 = p1->t.tr1; + if (opt = match(tree, table, nrleft, NOCVR)) return(opt); - tree1->t.tr1 = p1; + tree->t.tr1 = p1; } d2 = dcalc(p2, nrleft); } @@ -158,22 +158,22 @@ struct optab *match(tree1, table, nrleft, nocvt) union tree *tree1; struct table } /* - * Given a tree1, a code table, and a register, - * produce code to evaluate the tree1 with the appropriate table. + * Given a tree, a code table, and a register, + * produce code to evaluate the tree with the appropriate table. * Registers reg and upcan be used. * If there is a value, it is desired that it appear in reg. * The routine returns the register in which the value actually appears. - * This routine must work or there is an error1. + * This routine must work or there is an error. * If the table called for is cctab, sptab, or efftab, - * and tree1 can't be done using the called-for table, + * and tree can't be done using the called-for table, * another try is made. - * If the tree1 can't be compiled using cctab, regtab is + * If the tree can't be compiled using cctab, regtab is * used and a "tst" instruction is produced. - * If the tree1 can't be compiled using sptab, + * If the tree can't be compiled using sptab, * regtab is used and the register is pushed on the stack. - * If the tree1 can't be compiled using efftab, + * If the tree can't be compiled using efftab, * just use regtab. - * Regtab must succeed or an "op not found" error1 results. + * Regtab must succeed or an "op not found" error results. * * A number of special cases are recognized, and * there is an interaction with the optimizer routines. @@ -181,7 +181,7 @@ struct optab *match(tree1, table, nrleft, nocvt) union tree *tree1; struct table int rcexpr1(atree, atable, reg) union tree *atree; struct table *atable; int reg; { register int r; int modf, nargs, recurf; - register union tree *tree1; + register union tree *tree; register struct table *table; /*fprintf(stderr, "rcexpr1(0x%08x, 0x%08x, 0x%08x)\n", atree, atable, reg);*/ @@ -196,48 +196,48 @@ int rcexpr1(atree, atable, reg) union tree *atree; struct table *atable; int reg } } again: - if((tree1=atree)==0) + if((tree=atree)==0) return(0); - if (tree1->t.type==VOID) { + if (tree->t.type==VOID) { if (table!=efftab) error1("Illegal use of void"); - tree1->t.type = INT; + tree->t.type = INT; } - if (opdope1[tree1->t.op]&RELAT && tree1->t.tr2->t.op==CON - && tree1->t.tr2->c.value==0 + if (opdope1[tree->t.op]&RELAT && tree->t.tr2->t.op==CON + && tree->t.tr2->c.value==0 && table==cctab) - tree1 = atree = tree1->t.tr1; + tree = atree = tree->t.tr1; /* * fieldselect(...) : in efftab mode, * ignore the select, otherwise * do the shift and mask. */ - if (tree1->t.op == FSELT) { + if (tree->t.op == FSELT) { if (table==efftab) - atree = tree1 = tree1->t.tr1; + atree = tree = tree->t.tr1; else { - tree1->t.op = FSEL; - atree = tree1 = optim(tree1); + tree->t.op = FSEL; + atree = tree = optim(tree); } } - switch (tree1->t.op) { + switch (tree->t.op) { /* * Structure assignments */ /* case STRASG:*/ case ASSIGN: - if (tree1->t.type != STRUCT) + if (tree->t.type != STRUCT) break; - strasg(tree1); + strasg(tree); return(0); /* * An initializing expression */ case INIT: - tree1 = optim(tree1); - doinit(tree1->t.type, tree1->t.tr1); + tree = optim(tree); + doinit(tree->t.type, tree->t.tr1); return(0); /* @@ -245,13 +245,13 @@ again: * for a switch or a return */ case RFORCE: - if (tree1->t.type == STRUCT) { - strasg(tree1); + if (tree->t.type == STRUCT) { + strasg(tree); return(0); } - tree1 = tree1->t.tr1; - if((r=rcexpr1(tree1, regtab, reg)) != 0) - movreg(r, 0, tree1); + tree = tree->t.tr1; + if((r=rcexpr1(tree, regtab, reg)) != 0) + movreg(r, 0, tree); return(0); /* @@ -259,9 +259,9 @@ again: */ case SEQNC: r = nstack; - rcexpr1(tree1->t.tr1, efftab, reg); + rcexpr1(tree->t.tr1, efftab, reg); nstack = r; - atree = tree1 = tree1->t.tr2; + atree = tree = tree->t.tr2; goto again; /* @@ -271,8 +271,8 @@ again: */ case ANDN: if (table==cctab) { - tree1->t.op = TAND; - tree1->t.tr2 = optim(tnode1(COMPL, tree1->t.type, tree1->t.tr2, TNULL)); + tree->t.op = TAND; + tree->t.tr2 = optim(tnode1(COMPL, tree->t.type, tree->t.tr2, TNULL)); } break; @@ -301,30 +301,30 @@ again: * stop working. The compiler has been tested in all these * different cases with the catch commented out and all the * code generated was correct. So what was it here for? - * If a strange error1 crops up, uncommenting the catch might + * If a strange error crops up, uncommenting the catch might * be tried ... */ - if (tree1->t.tr1->t.op!=NAME || tree1->t.tr1->n.class!=EXTERN) { + if (tree->t.tr1->t.op!=NAME || tree->t.tr1->n.class!=EXTERN) { nargs++; nstack++; } #endif - tree1 = tree1->t.tr2; - if(tree1->t.op) { - while (tree1->t.op==COMMA) { - r += comarg(tree1->t.tr2, &modf); - tree1 = tree1->t.tr1; + tree = tree->t.tr2; + if(tree->t.op) { + while (tree->t.op==COMMA) { + r += comarg(tree->t.tr2, &modf); + tree = tree->t.tr1; nargs++; } - r += comarg(tree1, &modf); + r += comarg(tree, &modf); nargs++; } - tree1 = atree; - tree1->t.op = CALL2; - if (modf && tree1->t.tr1->t.op==NAME - && tree1->t.tr1->n.class==EXTERN) - tree1->t.op = CALL1; - if (cexpr(tree1, regtab, reg)<0) + tree = atree; + tree->t.op = CALL2; + if (modf && tree->t.tr1->t.op==NAME + && tree->t.tr1->n.class==EXTERN) + tree->t.op = CALL1; + if (cexpr(tree, regtab, reg)<0) error1("compiler botch: call"); popstk(r); nstack -= nargs; @@ -338,32 +338,32 @@ again: */ case ASULSH: /* 18 */ case ULSH: /* 17 */ - if (tree1->t.type != LONG && tree1->t.type != UNLONG) + if (tree->t.type != LONG && tree->t.type != UNLONG) break; - if (tree1->t.tr2->t.op==ITOL) - tree1->t.tr2 = tree1->t.tr2->t.tr1; + if (tree->t.tr2->t.op==ITOL) + tree->t.tr2 = tree->t.tr2->t.tr1; else - tree1->t.tr2 = optim(tnode1(LTOI,INT,tree1->t.tr2,TNULL)); - if (tree1->t.op==ASULSH) + tree->t.tr2 = optim(tnode1(LTOI,INT,tree->t.tr2,TNULL)); + if (tree->t.op==ASULSH) { - tree1->t.op = UASLSHL; - tree1->t.tr1 = tnode1(AMPER, LONG+PTR, tree1->t.tr1, TNULL); + tree->t.op = UASLSHL; + tree->t.tr1 = tnode1(AMPER, LONG+PTR, tree->t.tr1, TNULL); } else - tree1->t.op = ULLSHIFT; + tree->t.op = ULLSHIFT; break; case ASLSH: case LSHIFT: - if (tree1->t.type==LONG || tree1->t.type==UNLONG) { - if (tree1->t.tr2->t.op==ITOL) - tree1->t.tr2 = tree1->t.tr2->t.tr1; + if (tree->t.type==LONG || tree->t.type==UNLONG) { + if (tree->t.tr2->t.op==ITOL) + tree->t.tr2 = tree->t.tr2->t.tr1; else - tree1->t.tr2 = optim(tnode1(LTOI,INT,tree1->t.tr2,TNULL)); - if (tree1->t.op==ASLSH) - tree1->t.op = ASLSHL; + tree->t.tr2 = optim(tnode1(LTOI,INT,tree->t.tr2,TNULL)); + if (tree->t.op==ASLSH) + tree->t.op = ASLSHL; else - tree1->t.op = LLSHIFT; + tree->t.op = LLSHIFT; } break; @@ -372,16 +372,16 @@ again: */ case TIMES: case ASTIMES: - tree1 = pow2(tree1); + tree = pow2(tree); } /* * Try to find postfix ++ and -- operators that can be * pulled out and done after the rest of the expression */ if (table!=cctab && table!=cregtab && recurf<2 - && (opdope1[tree1->t.op]&LEAF)==0) { + && (opdope1[tree->t.op]&LEAF)==0) { if (r=delay(&atree, table, reg)) { - tree1 = atree; + tree = atree; table = efftab; reg = r-1; } @@ -394,22 +394,22 @@ again: if (table==cctab && atree->t.op==NAME) return(reg); } - tree1 = atree; - if (table==efftab && tree1->t.op==NAME) + tree = atree; + if (table==efftab && tree->t.op==NAME) return(reg); - if ((r=cexpr(tree1, table, reg))>=0) { - if (table==cregtab && (tree1->t.op==INCAFT - || tree1->t.op==DECAFT || tree1->t.op==TIMES)) + if ((r=cexpr(tree, table, reg))>=0) { + if (table==cregtab && (tree->t.op==INCAFT + || tree->t.op==DECAFT || tree->t.op==TIMES)) goto fixup; return(r); } - if (table!=regtab && (table!=cctab||(opdope1[tree1->t.op]&RELAT)==0)) { - if((r=cexpr(tree1, regtab, reg))>=0) { + if (table!=regtab && (table!=cctab||(opdope1[tree->t.op]&RELAT)==0)) { + if((r=cexpr(tree, regtab, reg))>=0) { fixup: - modf = isfloat(tree1); - dbprint(tree1->t.op); + modf = isfloat(tree); + dbprint(tree->t.op); if (table==sptab || table==lsptab) { - if (tree1->t.type==LONG || tree1->t.type==UNLONG){ + if (tree->t.type==LONG || tree->t.type==UNLONG){ fprintf(temp_fp[temp_fi], /*printf(*/"mov\tr%d,-(sp)\n",r+1); nstack++; } @@ -425,34 +425,34 @@ again: /* * Special grace for unsigned chars as right operands */ - if (opdope1[tree1->t.op]&BINARY && tree1->t.tr2->t.type==UNCHAR) { - tree1->t.tr2 = tnode1(LOAD, UNSIGN, tree1->t.tr2, TNULL); - return(rcexpr1(tree1, table, reg)); + if (opdope1[tree->t.op]&BINARY && tree->t.tr2->t.type==UNCHAR) { + tree->t.tr2 = tnode1(LOAD, UNSIGN, tree->t.tr2, TNULL); + return(rcexpr1(tree, table, reg)); } /* * There's a last chance for this operator */ - if (tree1->t.op==LTOI) { - r = rcexpr1(tree1->t.tr1, regtab, reg); + if (tree->t.op==LTOI) { + r = rcexpr1(tree->t.tr1, regtab, reg); if (r >= 0) { r++; goto fixup; } } - r = tree1->t.op; - if (tree1->t.type == STRUCT) + r = tree->t.op; + if (tree->t.type == STRUCT) error1("Illegal operation on structure"); else if (r > 0 && r < UASLSHL && opntab[r]) error1("No code table for op: %s(%d) type: %d", opntab[r], r, - tree1->t.type); + tree->t.type); else error1("No code table for op %d", r); return(reg); } /* - * Try to compile the tree1 with the code table using + * Try to compile the tree with the code table using * registers areg and up. If successful, * return the register where the value actually ended up. * If unsuccessful, return -1. @@ -460,7 +460,7 @@ again: * Most of the work is the macro-expansion of the * code table. */ -int cexpr(tree1, table, areg) register union tree *tree1; struct table *table; int areg; { +int cexpr(tree, table, areg) register union tree *tree; struct table *table; int areg; { int c, r; register union tree *p, *p1; struct table *ctable; @@ -470,15 +470,15 @@ int cexpr(tree1, table, areg) register union tree *tree1; struct table *table; i struct optab *opt; reg = areg; - p1 = tree1->t.tr2; - c = tree1->t.op; + p1 = tree->t.tr2; + c = tree->t.op; opd = opdope1[c]; /* * When the value of a relational or a logical expression is * desired, more work must be done. */ if ((opd&RELAT||c==LOGAND||c==LOGOR||c==EXCLA) && table!=cctab) { - cbranch1(tree1, c=isn1++, 1, reg); + cbranch1(tree, c=isn1++, 1, reg); rcexpr1((union tree *)&czero, table, reg); branch1(isn1, 0, 0); label1(c); @@ -489,7 +489,7 @@ int cexpr(tree1, table, areg) register union tree *tree1; struct table *table; i if(c==QUEST) { if (table==cctab) return(-1); - cbranch1(tree1->t.tr1, c=isn1++, 0, reg); + cbranch1(tree->t.tr1, c=isn1++, 0, reg); flag = nstack; rreg = rcexpr1(p1->t.tr1, table, reg); nstack = flag; @@ -497,40 +497,40 @@ int cexpr(tree1, table, areg) register union tree *tree1; struct table *table; i label1(c); reg = rcexpr1(p1->t.tr2, table, rreg); if (rreg!=reg) - movreg(reg, rreg, tree1->t.tr2); + movreg(reg, rreg, tree->t.tr2); label1(r); return(rreg); } - reg = oddreg(tree1, reg); + reg = oddreg(tree, reg); reg1 = reg+1; /* * long values take 2 registers. */ - if ((tree1->t.type==LONG||tree1->t.type==UNLONG||opd&RELAT&&(tree1->t.tr1->t.type==LONG||tree1->t.tr1->t.type==UNLONG)) - && tree1->t.op!=ITOL) + if ((tree->t.type==LONG||tree->t.type==UNLONG||opd&RELAT&&(tree->t.tr1->t.type==LONG||tree->t.tr1->t.type==UNLONG)) + && tree->t.op!=ITOL) reg1++; /* - * Leaves of the expression tree1 + * Leaves of the expression tree */ - if ((r = chkleaf(tree1, table, reg)) >= 0) + if ((r = chkleaf(tree, table, reg)) >= 0) return(r); /* * x + (-1) is better done as x-1. */ - if (tree1->t.op==PLUS||tree1->t.op==ASPLUS) { - if ((p1=tree1->t.tr2)->t.op==CON && p1->c.value==-1) { + if (tree->t.op==PLUS||tree->t.op==ASPLUS) { + if ((p1=tree->t.tr2)->t.op==CON && p1->c.value==-1) { p1->c.value = -p1->c.value; - tree1->t.op += (MINUS-PLUS); + tree->t.op += (MINUS-PLUS); } } /* * Because of a peculiarity of the PDP11 table * char = *intreg++ and *--intreg cannot go through. */ - if (tree1->t.tr2 && (tree1->t.tr2->t.op==AUTOI||tree1->t.tr2->t.op==AUTOD) - && (tree1->t.tr1->t.type==CHAR || tree1->t.tr1->t.type==UNCHAR) - && tree1->t.tr2->t.type!=CHAR && tree1->t.tr2->t.type!=UNCHAR) - tree1->t.tr2 = tnode1(LOAD, tree1->t.tr2->t.type, tree1->t.tr2, TNULL); + if (tree->t.tr2 && (tree->t.tr2->t.op==AUTOI||tree->t.tr2->t.op==AUTOD) + && (tree->t.tr1->t.type==CHAR || tree->t.tr1->t.type==UNCHAR) + && tree->t.tr2->t.type!=CHAR && tree->t.tr2->t.type!=UNCHAR) + tree->t.tr2 = tnode1(LOAD, tree->t.tr2->t.type, tree->t.tr2, TNULL); /* * Another peculiarity of the PDP11 table manifested itself when * amplifying the move3: table. The same case which optimizes @@ -545,10 +545,10 @@ int cexpr(tree1, table, areg) register union tree *tree1; struct table *table; i * u_char handling in the compiler is a bit awkward, it would be nice * if %aub in the tables had a more unique meaning. */ - if (tree1->t.tr2 && tree1->t.tr1->t.op == NAME - && tree1->t.tr1->n.class == REG && tree1->t.op == ASSIGN - && tree1->t.tr2->t.type == UNCHAR) - tree1->t.tr2 = tnode1(LOAD, UNSIGN, tree1->t.tr2, TNULL); + if (tree->t.tr2 && tree->t.tr1->t.op == NAME + && tree->t.tr1->n.class == REG && tree->t.op == ASSIGN + && tree->t.tr2->t.type == UNCHAR) + tree->t.tr2 = tnode1(LOAD, UNSIGN, tree->t.tr2, TNULL); if (table==cregtab) table = regtab; /* @@ -567,14 +567,14 @@ int cexpr(tree1, table, areg) register union tree *tree1; struct table *table; i * r = nreg - reg - (reg-areg) - (reg1-reg-1); */ r = nreg - reg + areg - reg1 + 1; - if (table!=cctab || c==INCAFT || c==DECAFT || tree1->t.type==LONG || tree1->t.type==UNLONG -/* || c==ASRSH || c==ASLSH || c==ASULSH || tree1->t.tr1->t.type==UNCHAR */ + if (table!=cctab || c==INCAFT || c==DECAFT || tree->t.type==LONG || tree->t.type==UNLONG +/* || c==ASRSH || c==ASLSH || c==ASULSH || tree->t.tr1->t.type==UNCHAR */ || c==ASRSH || c==ASLSH || c==ASULSH - || (opt = match(tree1, efftab, r, 0)) == 0) - if ((opt=match(tree1, table, r, 0))==0) + || (opt = match(tree, efftab, r, 0)) == 0) + if ((opt=match(tree, table, r, 0))==0) return(-1); string = opt->tabstring; - p1 = tree1->t.tr1; + p1 = tree->t.tr1; if (p1->t.op==FCON && p1->f.value>0) { #ifdef pdp11 /* nonportable */ @@ -593,8 +593,8 @@ int cexpr(tree1, table, areg) register union tree *tree1; struct table *table; i p1->f/*c*/.value = -p1->f/*c*/.value; } p2 = 0; - if (opdope1[tree1->t.op]&BINARY) { - p2 = tree1->t.tr2; + if (opdope1[tree->t.op]&BINARY) { + p2 = tree->t.tr2; if (p2->t.op==FCON && p2->f.value>0) { #ifdef pdp11 /* nonportable */ @@ -624,15 +624,15 @@ loop: switch (c) { case '\n': - dbprint(tree1->t.op); + dbprint(tree->t.op); break; case '\0': - if (!isfloat(tree1)) - if (tree1->t.op==DIVIDE||tree1->t.op==ASDIV) + if (!isfloat(tree)) + if (tree->t.op==DIVIDE||tree->t.op==ASDIV) reg--; - if (table==regtab && (opdope1[tree1->t.op]&ASSGOP)) { - if (tree1->t.tr1->t.type==CHAR) + if (table==regtab && (opdope1[tree->t.op]&ASSGOP)) { + if (tree->t.tr1->t.type==CHAR) fprintf(temp_fp[temp_fi], /*printf(*/"movb r%d,r%d\n", reg, reg); } return(reg); @@ -666,20 +666,20 @@ loop: string++; else c = 0; - prins(tree1->t.op, c, instab, 0); + prins(tree->t.op, c, instab, 0); goto loop; /* B1 */ case 'C': if ((opd&LEAF) != 0) - p = tree1; + p = tree; else p = p1; goto pbyte; /* BF */ case 'P': - p = tree1; + p = tree; goto pb1; /* B2 */ @@ -698,7 +698,7 @@ loop: if (p1->t.type==CHAR || p2->t.type==CHAR || p1->t.type==UNCHAR || p2->t.type==UNCHAR) fputc('b', temp_fp[temp_fi]) /*putchar('b')*/; - p = tree1; + p = tree; goto pb1; /* F */ @@ -715,7 +715,7 @@ loop: /* H */ case 'H': - p = tree1; + p = tree; flag = 04; subtre: @@ -736,8 +736,8 @@ loop: if ((c&04)!=0) ctable = cctab; if ((flag&01) && ctable==regtab && (c&01)==0 - && ((c&040)||tree1->t.op==DIVIDE||tree1->t.op==MOD - || tree1->t.op==ASDIV||tree1->t.op==ASMOD||tree1->t.op==ITOL)) + && ((c&040)||tree->t.op==DIVIDE||tree->t.op==MOD + || tree->t.op==ASDIV||tree->t.op==ASMOD||tree->t.op==ITOL)) ctable = cregtab; if ((c&01)!=0) { p = p->t.tr1; @@ -765,8 +765,8 @@ loop: else reg1 = rreg; } else if (rreg!=reg) - if ((c&020)==0 && oddreg(tree1, 0)==0 && tree1->t.type!=LONG - && tree1->t.type!=UNLONG + if ((c&020)==0 && oddreg(tree, 0)==0 && tree->t.type!=LONG + && tree->t.type!=UNLONG && (flag&04 || flag&01&&xdcalc(p2,nreg-rreg-1)<=(opt->tabdeg2&077) || flag&02&&xdcalc(p1,nreg-rreg-1)<=(opt->tabdeg1&077))) { @@ -793,7 +793,7 @@ loop: string++; r++; } - if (r>nreg || r>=4 && tree1->t.type==DOUBLE) { + if (r>nreg || r>=4 && tree->t.type==DOUBLE) { if (regpanic) error1("Register overflow: simplify expression"); else @@ -855,7 +855,7 @@ loop: goto loop; case 'V': /* adc sbc, clr, or sxt as required for longs */ - switch(tree1->t.op) { + switch(tree->t.op) { case PLUS: case ASPLUS: case INCBEF: @@ -872,16 +872,16 @@ loop: break; case ASSIGN: - p = tree1->t.tr2; + p = tree->t.tr2; goto lcasev; case ASDIV: case ASMOD: case ASULSH: - p = tree1->t.tr1; + p = tree->t.tr1; lcasev: if (p->t.type!=LONG && p->t.type!=UNLONG) { - if (uns(p) || uns(tree1->t.tr2)) + if (uns(p) || uns(tree->t.tr2)) fprintf(temp_fp[temp_fi], /*printf(*/"clr"); else fprintf(temp_fp[temp_fi], /*printf(*/"sxt"); @@ -897,7 +897,7 @@ loop: * Mask used in field assignments */ case 'Z': - fprintf(temp_fp[temp_fi], /*printf(*/"$%o", UNS(tree1->F.mask)); + fprintf(temp_fp[temp_fi], /*printf(*/"$%o", UNS(tree->F.mask)); goto loop; /* @@ -916,7 +916,7 @@ loop: /* * This routine just calls sreorder (below) - * on the subtrees and then on the tree1 itself. + * on the subtrees and then on the tree itself. * It returns non-zero if anything changed. */ int reorder(treep, table, reg) union tree **treep; struct table *table; int reg; { @@ -944,8 +944,8 @@ int reorder(treep, table, reg) union tree **treep; struct table *table; int reg; * Basically this routine carries out two kinds of optimization. * First, it observes that "x + (reg = y)" where actually * the = is any assignment op is better done as "reg=y; x+reg". - * In this case rcexpr1 is called to do the first part and the - * tree1 is modified so the name of the register + * In this case rcexpr is called to do the first part and the + * tree is modified so the name of the register * replaces the assignment. * Moreover, expressions like "reg = x+y" are best done as * "reg = x; reg += y" (so long as "reg" and "y" are not the same!). @@ -1038,8 +1038,8 @@ int sreorder(treep, table, reg, recurf) union tree **treep; struct table *table; * It observes that "x + y++" is better * treated as "x + y; y++". * If the operator is ++ or -- itself, - * it calls rcexpr1 to load the operand, letting - * the calling instance of rcexpr1 to do the + * it calls rcexpr to load the operand, letting + * the calling instance of rcexpr to do the * ++ using efftab. * Otherwise it uses sdelay to search for inc/dec * among the operands. @@ -1127,7 +1127,7 @@ union tree *paint(tp, type) register union tree *tp; register int type; { } /* - * Copy a tree1 node for a register variable. + * Copy a tree node for a register variable. * Used by sdelay because if *reg-- is turned * into *reg; reg-- the *reg will in turn * be changed to some offset class, accidentally @@ -1150,19 +1150,19 @@ union tree *ncopy(p) register union tree *p; { } /* - * If the tree1 can be immediately loaded into a register, + * If the tree can be immediately loaded into a register, * produce code to do so and return success. */ -int chkleaf(tree1, table, reg) register union tree *tree1; struct table *table; int reg; { +int chkleaf(tree, table, reg) register union tree *tree; struct table *table; int reg; { struct tnode lbuf; - /*fprintf(stderr, "chkleaf(0x%08x, 0x%08x, 0x%08x)\n", tree1, table, reg);*/ - if (tree1->t.op!=STAR && dcalc(tree1, nreg-reg) > 12) + /*fprintf(stderr, "chkleaf(0x%08x, 0x%08x, 0x%08x)\n", tree, table, reg);*/ + if (tree->t.op!=STAR && dcalc(tree, nreg-reg) > 12) return(-1); lbuf.op = LOAD; - lbuf.type = tree1->t.type; - lbuf.degree = tree1->t.degree; - lbuf.tr1 = tree1; + lbuf.type = tree->t.type; + lbuf.degree = tree->t.degree; + lbuf.tr1 = tree; #if 1 /* can't have garbage in lbuf.tr2, cexpr() will deref it if non-NULL */ lbuf.tr2 = NULL; #endif @@ -1176,32 +1176,32 @@ int chkleaf(tree1, table, reg) register union tree *tree1; struct table *table; * Return the number of bytes pushed, * for future popping. */ -int comarg(tree1, flagp) register union tree *tree1; int *flagp; { +int comarg(tree, flagp) register union tree *tree; int *flagp; { register int retval; int i; int size; - if (/*tree1->t.op==STRASG*/tree1->t.type==STRUCT) { - /* size = tree1->F.mask; - tree1 = tree1->t.tr1;*/ - size = tree1->t.strp->S.ssize; - tree1 = strfunc(tree1); + if (/*tree->t.op==STRASG*/tree->t.type==STRUCT) { + /* size = tree->F.mask; + tree = tree->t.tr1;*/ + size = tree->t.strp->S.ssize; + tree = strfunc(tree); if (size <= sizeof(_INT)) { - paint(tree1, INT); + paint(tree, INT); goto normal; } if (size <= sizeof(_LONG)) { - paint(tree1, LONG); + paint(tree, LONG); goto normal; } - if (tree1->t.op!=NAME && tree1->t.op!=STAR) { + if (tree->t.op!=NAME && tree->t.op!=STAR) { error1("Unimplemented structure assignment"); return(0); } - tree1 = tnode1(AMPER, STRUCT+PTR, tree1, TNULL); - tree1 = tnode1(PLUS, STRUCT+PTR, tree1, tconst1(size, INT)); - tree1 = optim(tree1); - retval = rcexpr1(tree1, regtab, 0); + tree = tnode1(AMPER, STRUCT+PTR, tree, TNULL); + tree = tnode1(PLUS, STRUCT+PTR, tree, tconst(size, INT)); + tree = optim(tree); + retval = rcexpr1(tree, regtab, 0); size >>= 1; if (size <= 5) { for (i=0; it.type==LONG || tree1->t.type==UNLONG) { - rcexpr1(tree1, sptab, 0); - retval = arlength(tree1->t.type); + if (nstack || isfloat(tree) || tree->t.type==LONG || tree->t.type==UNLONG) { + rcexpr1(tree, sptab, 0); + retval = arlength(tree->t.type); } else { (*flagp)++; - rcexpr1(tree1, lsptab, 0); + rcexpr1(tree, lsptab, 0); retval = 0; } return(retval); @@ -1238,14 +1238,14 @@ union tree *strfunc(tp) register union tree *tp; { /* * Compile an initializing expression */ -void doinit(type, tree1) register int type; register union tree *tree1; { +void doinit(type, tree) register int type; register union tree *tree; { _FLOAT sfval; _DOUBLE fval; _LONG lval; if (type==CHAR || type==UNCHAR) { fprintf(temp_fp[temp_fi], /*printf(*/".byte "); - if (tree1->t.type&XTYPE) + if (tree->t.type&XTYPE) goto illinit; type = INT; } @@ -1254,28 +1254,28 @@ void doinit(type, tree1) register int type; register union tree *tree1; { switch (type) { case INT: case UNSIGN: - if (tree1->t.op==FTOI) { - if (tree1->t.tr1->t.op!=FCON && tree1->t.tr1->t.op!=SFCON) + if (tree->t.op==FTOI) { + if (tree->t.tr1->t.op!=FCON && tree->t.tr1->t.op!=SFCON) goto illinit; - tree1 = tree1->t.tr1; + tree = tree->t.tr1; #ifdef pdp11 - tree1->c.value = tree1->f.fvalue; + tree->c.value = tree->f.fvalue; #else - tree1->c.value = fp_double_to_int(tree1->f.fvalue); + tree->c.value = fp_double_to_int(tree->f.fvalue); #endif - tree1->t.op = CON; - } else if (tree1->t.op==LTOI) { - if (tree1->t.tr1->t.op!=LCON) + tree->t.op = CON; + } else if (tree->t.op==LTOI) { + if (tree->t.tr1->t.op!=LCON) goto illinit; - tree1 = tree1->t.tr1; - lval = tree1->l.lvalue; - tree1->t.op = CON; - tree1->c.value = lval; + tree = tree->t.tr1; + lval = tree->l.lvalue; + tree->t.op = CON; + tree->c.value = lval; } - if (tree1->t.op == CON) - fprintf(temp_fp[temp_fi], /*printf(*/"%o\n", UNS(tree1->c.value)); - else if (tree1->t.op==AMPER) { - pname(tree1->t.tr1, 0); + if (tree->t.op == CON) + fprintf(temp_fp[temp_fi], /*printf(*/"%o\n", UNS(tree->c.value)); + else if (tree->t.op==AMPER) { + pname(tree->t.tr1, 0); fputc('\n', temp_fp[temp_fi]) /*putchar('\n')*/; } else goto illinit; @@ -1283,26 +1283,26 @@ void doinit(type, tree1) register int type; register union tree *tree1; { case DOUBLE: case FLOAT: - if (tree1->t.op==ITOF) { - if (tree1->t.tr1->t.op==CON) { + if (tree->t.op==ITOF) { + if (tree->t.tr1->t.op==CON) { /* note: this should be changed to respect the signedness of the int */ #ifdef pdp11 - fval = tree1->t.tr1->c.value; + fval = tree->t.tr1->c.value; #else - fval = fp_int_to_double(tree1->t.tr1->c.value); + fval = fp_int_to_double(tree->t.tr1->c.value); #endif } else goto illinit; - } else if (tree1->t.op==FCON || tree1->t.op==SFCON) { - fval = tree1->f.fvalue; - } else if (tree1->t.op==LTOF) { - if (tree1->t.tr1->t.op!=LCON) + } else if (tree->t.op==FCON || tree->t.op==SFCON) { + fval = tree->f.fvalue; + } else if (tree->t.op==LTOF) { + if (tree->t.tr1->t.op!=LCON) goto illinit; /* note: this should be changed to respect the signedness of the long */ #ifdef pdp11 - fval = tree1->t.tr1->l.lvalue; + fval = tree->t.tr1->l.lvalue; #else - fval = fp_long_to_double(tree1->t.tr1->l.lvalue); + fval = fp_long_to_double(tree->t.tr1->l.lvalue); #endif } else goto illinit; @@ -1340,26 +1340,26 @@ void doinit(type, tree1) register int type; register union tree *tree1; { case UNLONG: case LONG: - if (tree1->t.op==FTOL) { - tree1 = tree1->t.tr1; - if (tree1->t.op==SFCON) - tree1->t.op = FCON; - if (tree1->t.op!= FCON) + if (tree->t.op==FTOL) { + tree = tree->t.tr1; + if (tree->t.op==SFCON) + tree->t.op = FCON; + if (tree->t.op!= FCON) goto illinit; #ifdef pdp11 - lval = tree1->f.fvalue; + lval = tree->f.fvalue; #else - lval = fp_double_to_long(tree1->f.fvalue); + lval = fp_double_to_long(tree->f.fvalue); #endif - } else if (tree1->t.op==ITOL) { - if (tree1->t.tr1->t.op != CON) + } else if (tree->t.op==ITOL) { + if (tree->t.tr1->t.op != CON) goto illinit; - if (uns(tree1->t.tr1)) - lval = (_UNSIGNED_INT)tree1->t.tr1->c.value; + if (uns(tree->t.tr1)) + lval = (_UNSIGNED_INT)tree->t.tr1->c.value; else - lval = tree1->t.tr1->c.value; - } else if (tree1->t.op==LCON) { - lval = tree1->l.lvalue; + lval = tree->t.tr1->c.value; + } else if (tree->t.op==LCON) { + lval = tree->l.lvalue; } else goto illinit; /* nonportable */ @@ -1370,15 +1370,15 @@ illinit: error1("Illegal initialization"); } -void movreg(r0, r1, tree1) int r0; int r1; union tree *tree1; { +void movreg(r0, r1, tree) int r0; int r1; union tree *tree; { register char *s; char c; if (r0==r1) return; - if (tree1->t.type==LONG || tree1->t.type == UNLONG) { + if (tree->t.type==LONG || tree->t.type == UNLONG) { if (r0>=nreg || r1>=nreg) { - error1("register overflow: compiler error1"); + error1("register overflow: compiler error"); } s = "mov r%d,r%d\nmov r%d,r%d\n"; if (r0 < r1) @@ -1387,6 +1387,6 @@ void movreg(r0, r1, tree1) int r0; int r1; union tree *tree1; { fprintf(temp_fp[temp_fi], /*printf(*/s, r0,r1,r0+1,r1+1); return; } - c = isfloat(tree1); + c = isfloat(tree); fprintf(temp_fp[temp_fi], /*printf(*/"mov%.1s r%d,r%d\n", &c, r0, r1); } diff --git a/c11.c b/c11.c index 45685ec..fbb8a94 100644 --- a/c11.c +++ b/c11.c @@ -94,7 +94,7 @@ loop: return; } - error1("Compiler error1: pname"); + error1("Compiler error: pname"); return; case AMPER: @@ -118,7 +118,7 @@ loop: goto loop; } - error1("compiler error1: bad pname"); + error1("compiler error: bad pname"); } void pbase(p) register union tree *p; { @@ -443,26 +443,26 @@ void breq(v, l) int v; int l; { } int sort(afp, alp) struct swtab *afp; struct swtab *alp; { - register struct swtab *cp1, *fp, *lp; + register struct swtab *cp, *fp, *lp; int intch, t; fp = afp; lp = alp; while (fp < --lp) { intch = 0; - for (cp1=fp; cp1swval == cp1[1].swval) { - error1("Duplicate case (%d)", cp1->swval); + for (cp=fp; cpswval == cp[1].swval) { + error1("Duplicate case (%d)", cp->swval); return(1); } - if (cp1->swval > cp1[1].swval) { + if (cp->swval > cp[1].swval) { intch++; - t = cp1->swval; - cp1->swval = cp1[1].swval; - cp1[1].swval = t; - t = cp1->swlab; - cp1->swlab = cp1[1].swlab; - cp1[1].swlab = t; + t = cp->swval; + cp->swval = cp[1].swval; + cp[1].swval = t; + t = cp->swlab; + cp->swlab = cp[1].swlab; + cp[1].swlab = t; } } if (intch==0) @@ -471,157 +471,157 @@ int sort(afp, alp) struct swtab *afp; struct swtab *alp; { return(0); } -int ispow2(tree1) register union tree *tree1; { +int ispow2(tree) register union tree *tree; { register int d; - if (!isfloat(tree1) && tree1->t.tr2->t.op==CON) { - d = tree1->t.tr2->c.value; + if (!isfloat(tree) && tree->t.tr2->t.op==CON) { + d = tree->t.tr2->c.value; if (d>1 && (d&(d-1))==0) return(d); } return(0); } -union tree *pow2(tree1) register union tree *tree1; { +union tree *pow2(tree) register union tree *tree; { register int d, i; - if (d = ispow2(tree1)) { + if (d = ispow2(tree)) { for (i=0; (d>>=1)!=0; i++); - tree1->t.tr2->c.value = i; - switch (tree1->t.op) { + tree->t.tr2->c.value = i; + switch (tree->t.op) { case TIMES: - tree1->t.op = LSHIFT; + tree->t.op = LSHIFT; break; case ASTIMES: - tree1->t.op = ASLSH; + tree->t.op = ASLSH; break; case PTOI: - if (i==1 && tree1->t.tr1->t.op==MINUS && !isconstant(tree1->t.tr1->t.tr2)) { - tree1->t.op = PTOI1; - tree1->t.tr1 = tnode1(LTOI, INT, tree1->t.tr1, TNULL); - return(optim(tree1)); + if (i==1 && tree->t.tr1->t.op==MINUS && !isconstant(tree->t.tr1->t.tr2)) { + tree->t.op = PTOI1; + tree->t.tr1 = tnode1(LTOI, INT, tree->t.tr1, TNULL); + return(optim(tree)); } - tree1->t.op = LLSHIFT; - tree1->t.tr2->c.value = -i; - i = tree1->t.type; - tree1->t.type = LONG; - tree1 = tnode1(LTOI, i, tree1, TNULL); + tree->t.op = LLSHIFT; + tree->t.tr2->c.value = -i; + i = tree->t.type; + tree->t.type = LONG; + tree = tnode1(LTOI, i, tree, TNULL); break; case DIVIDE: - tree1->t.op = ULSH; - tree1->t.tr2->c.value = -i; + tree->t.op = ULSH; + tree->t.tr2->c.value = -i; break; case ASDIV: - tree1->t.op = ASULSH; - tree1->t.tr2->c.value = -i; + tree->t.op = ASULSH; + tree->t.tr2->c.value = -i; break; case MOD: - tree1->t.op = AND; - tree1->t.tr2->c.value = (1<t.op = AND; + tree->t.tr2->c.value = (1<t.op = ASAND; - tree1->t.tr2->c.value = (1<t.op = ASAND; + tree->t.tr2->c.value = (1<t.op) { + switch(tree->t.op) { case LOGAND: if (cond) { - cbranch1(tree1->t.tr1, l1=isn1++, 0, reg); - cbranch1(tree1->t.tr2, lbl, 1, reg); + cbranch1(tree->t.tr1, l1=isn1++, 0, reg); + cbranch1(tree->t.tr2, lbl, 1, reg); label1(l1); } else { - cbranch1(tree1->t.tr1, lbl, 0, reg); - cbranch1(tree1->t.tr2, lbl, 0, reg); + cbranch1(tree->t.tr1, lbl, 0, reg); + cbranch1(tree->t.tr2, lbl, 0, reg); } return; case LOGOR: if (cond) { - cbranch1(tree1->t.tr1, lbl, 1, reg); - cbranch1(tree1->t.tr2, lbl, 1, reg); + cbranch1(tree->t.tr1, lbl, 1, reg); + cbranch1(tree->t.tr2, lbl, 1, reg); } else { - cbranch1(tree1->t.tr1, l1=isn1++, 1, reg); - cbranch1(tree1->t.tr2, lbl, 0, reg); + cbranch1(tree->t.tr1, l1=isn1++, 1, reg); + cbranch1(tree->t.tr2, lbl, 0, reg); label1(l1); } return; case EXCLA: - cbranch1(tree1->t.tr1, lbl, !cond, reg); + cbranch1(tree->t.tr1, lbl, !cond, reg); return; case SEQNC: - rcexpr1(tree1->t.tr1, efftab, reg); - atree = tree1->t.tr2; + rcexpr1(tree->t.tr1, efftab, reg); + atree = tree->t.tr2; goto again; case ITOL: - tree1 = tree1->t.tr1; + tree = tree->t.tr1; break; case QUEST: l1 = isn1; isn1 += 2; - cbranch1(tree1->t.tr1, l1, 0, reg); - cbranch1(tree1->t.tr2->t.tr1, lbl, cond, reg); + cbranch1(tree->t.tr1, l1, 0, reg); + cbranch1(tree->t.tr2->t.tr1, lbl, cond, reg); branch1(l1+1, 0, 0); label1(l1); - cbranch1(tree1->t.tr2->t.tr2, lbl, cond, reg); + cbranch1(tree->t.tr2->t.tr2, lbl, cond, reg); label1(l1+1); return; } - op = tree1->t.op; + op = tree->t.op; if (opdope1[op]&RELAT - && tree1->t.tr1->t.op==ITOL && tree1->t.tr2->t.op==ITOL - && uns(tree1->t.tr1->t.tr1) == uns(tree1->t.tr2->t.tr1)) { - tree1->t.tr1 = tree1->t.tr1->t.tr1; - tree1->t.tr2 = tree1->t.tr2->t.tr1; + && tree->t.tr1->t.op==ITOL && tree->t.tr2->t.op==ITOL + && uns(tree->t.tr1->t.tr1) == uns(tree->t.tr2->t.tr1)) { + tree->t.tr1 = tree->t.tr1->t.tr1; + tree->t.tr2 = tree->t.tr2->t.tr1; if (op>=LESSEQ && op<=GREAT - && uns(tree1->t.tr1)) - tree1->t.op = op = op+LESSEQP-LESSEQ; + && uns(tree->t.tr1)) + tree->t.op = op = op+LESSEQP-LESSEQ; } - if (tree1->t.type==LONG || tree1->t.type==UNLONG - || opdope1[op]&RELAT&&(tree1->t.tr1->t.type==LONG || tree1->t.tr1->t.type==UNLONG)) { - longrel(tree1, lbl, cond, reg); + if (tree->t.type==LONG || tree->t.type==UNLONG + || opdope1[op]&RELAT&&(tree->t.tr1->t.type==LONG || tree->t.tr1->t.type==UNLONG)) { + longrel(tree, lbl, cond, reg); return; } - rcexpr1(tree1, cctab, reg); - op = tree1->t.op; + rcexpr1(tree, cctab, reg); + op = tree->t.op; if ((opdope1[op]&RELAT)==0) op = NEQUAL; else { - l1 = tree1->t.tr2->t.op; - if ((l1==CON || l1==SFCON) && tree1->t.tr2->c.value==0) + l1 = tree->t.tr2->t.op; + if ((l1==CON || l1==SFCON) && tree->t.tr2->c.value==0) op += 200; /* special for ptr tests */ else op = maprel[op-EQUAL]; } - if (isfloat(tree1)) + if (isfloat(tree)) fprintf(temp_fp[temp_fi], /*printf(*/"cfcc\n"); branch1(lbl, op, !cond); } @@ -645,16 +645,16 @@ void branch1(lbl, aop, c) int lbl; int aop; int c; { void longrel(atree, lbl, cond, reg) union tree *atree; int lbl; int cond; int reg; { int xl1, xl2, xo, xz; register int op, isrel; - register union tree *tree1; + register union tree *tree; if (reg&01) reg++; reorder(&atree, cctab, reg); - tree1 = atree; + tree = atree; isrel = 0; - if (opdope1[tree1->t.op]&RELAT) { + if (opdope1[tree->t.op]&RELAT) { isrel++; - op = tree1->t.op; + op = tree->t.op; } else op = NEQUAL; if (!cond) @@ -666,14 +666,14 @@ void longrel(atree, lbl, cond, reg) union tree *atree; int lbl; int cond; int re xlab2 = 0; xop = op; xz = xzero; - xzero = !isrel || (tree1->t.tr2->t.op==ITOL && tree1->t.tr2->t.tr1->t.op==CON - && tree1->t.tr2->t.tr1->c.value==0); - if (tree1->t.op==ANDN) { - tree1->t.op = TAND; - tree1->t.tr2 = optim(tnode1(COMPL, LONG, tree1->t.tr2, TNULL)); + xzero = !isrel || (tree->t.tr2->t.op==ITOL && tree->t.tr2->t.tr1->t.op==CON + && tree->t.tr2->t.tr1->c.value==0); + if (tree->t.op==ANDN) { + tree->t.op = TAND; + tree->t.tr2 = optim(tnode1(COMPL, LONG, tree->t.tr2, TNULL)); } - if (cexpr(tree1, cctab, reg) < 0) { - reg = rcexpr1(tree1, regtab, reg); + if (cexpr(tree, cctab, reg) < 0) { + reg = rcexpr1(tree, regtab, reg); fprintf(temp_fp[temp_fi], /*printf(*/"ashc $0,r%d\n", reg); branch1(xlab1, op, 0); } @@ -833,7 +833,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl op = va_arg(argp, int) /*geti()*/; /*fprintf(stderr, "%d %d\n", op, (int)(sp - expstack));*/ /* if ((op&0177400) != 0177000) { - error1("Intermediate file error1"); + error1("Intermediate file error"); exit(1); }*/ lbl = 0; @@ -1014,7 +1014,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl case CON: t = va_arg(argp, int) /*geti()*/; - *sp++ = tconst1(va_arg(argp, int) /*geti()*/, t); + *sp++ = tconst(va_arg(argp, int) /*geti()*/, t); break; case LCON: @@ -1022,7 +1022,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl t = va_arg(argp, int) /*geti()*/; op = va_arg(argp, int) /*geti()*/; if (t==0 && op>=0 || t == -1 && op<0) { - *sp++ = tnode1(ITOL, LONG, tconst1(op, INT), TNULL); + *sp++ = tnode1(ITOL, LONG, tconst(op, INT), TNULL); break; } tp = getblk(sizeof(struct lconst)); @@ -1050,7 +1050,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl case FSEL: tp = tnode1(FSEL, va_arg(argp, int) /*geti()*/, *--sp, TNULL); t = va_arg(argp, int) /*geti()*/; - tp->t.tr2 = tnode1(COMMA, INT, tconst1(va_arg(argp, int) /*geti()*/, INT), tconst1(t, INT)); + tp->t.tr2 = tnode1(COMMA, INT, tconst(va_arg(argp, int) /*geti()*/, INT), tconst(t, INT)); if (tp->t.tr2->t.tr1->c.value==16) tp = paint(tp->t.tr1, tp->t.type); *sp++ = tp; diff --git a/c12.c b/c12.c index c6e539e..c62889c 100644 --- a/c12.c +++ b/c12.c @@ -13,12 +13,12 @@ #define min(a,b) (((a)<(b))?(a):(b)) #define max(a,b) (((a)>(b))?(a):(b)) -union tree *optim(tree1) register union tree *tree1; { - /*fprintf(stderr, "optim %d", tree1->t.op); - if ((opdope1[tree1->t.op] & LEAF) == 0) - fprintf(stderr, " left %d", tree1->t.tr1->t.op); - if (opdope1[tree1->t.op] & BINARY) - fprintf(stderr, " right %d", tree1->t.tr2->t.op); +union tree *optim(tree) register union tree *tree; { + /*fprintf(stderr, "optim %d", tree->t.op); + if ((opdope1[tree->t.op] & LEAF) == 0) + fprintf(stderr, " left %d", tree->t.tr1->t.op); + if (opdope1[tree->t.op] & BINARY) + fprintf(stderr, " right %d", tree->t.tr2->t.op); fprintf(stderr, "\n");*/ register int op, dope; int d1, d2; @@ -27,41 +27,41 @@ union tree *optim(tree1) register union tree *tree1; { union { double dv; _INT iv[4];} fp11; #endif - if (tree1==NULL) + if (tree==NULL) return(NULL); - if ((op = tree1->t.op)==0) - return(tree1); - if (op==NAME && tree1->n.class==AUTO) { - tree1->n.class = OFFS; - tree1->n.regno = 5; - tree1->n.offset = tree1->n.nloc; + if ((op = tree->t.op)==0) + return(tree); + if (op==NAME && tree->n.class==AUTO) { + tree->n.class = OFFS; + tree->n.regno = 5; + tree->n.offset = tree->n.nloc; } dope = opdope1[op]; if ((dope&LEAF) != 0) { if (op==FCON) { #ifdef pdp11 - fp11.dv = tree1->f.fvalue; + fp11.dv = tree->f.fvalue; if (fp11.iv[1]==0 && fp11.iv[2]==0 && fp11.iv[3]==0) { - tree1->t.op = SFCON; - tree1->f.value = fp11.iv[0]; + tree->t.op = SFCON; + tree->f.value = fp11.iv[0]; } #else - if (tree1->f.fvalue.l==0 - && (tree1->f.fvalue.h & 0xffff)==0) { - tree1->t.op = SFCON; - tree1->f.value = (int)(tree1->f.fvalue.h >> 16) & 0xffff; + if (tree->f.fvalue.l==0 + && (tree->f.fvalue.h & 0xffff)==0) { + tree->t.op = SFCON; + tree->f.value = (int)(tree->f.fvalue.h >> 16) & 0xffff; } #endif } - return(tree1); + return(tree); } if ((dope&BINARY) == 0) - return(unoptim(tree1)); + return(unoptim(tree)); /* is known to be binary */ - if (tree1->t.type==CHAR) - tree1->t.type = INT; + if (tree->t.type==CHAR) + tree->t.type = INT; switch(op) { /* * PDP-11 special: @@ -69,8 +69,8 @@ union tree *optim(tree1) register union tree *tree1; { * by complementing the RHS. */ case ASAND: - tree1->t.op = ASANDN; - tree1->t.tr2 = tnode1(COMPL, tree1->t.tr2->t.type, tree1->t.tr2, TNULL); + tree->t.op = ASANDN; + tree->t.tr2 = tnode1(COMPL, tree->t.tr2->t.type, tree->t.tr2, TNULL); break; /* @@ -78,16 +78,16 @@ union tree *optim(tree1) register union tree *tree1; { * Longs are just truncated. */ case LTOP: - tree1->t.op = ITOP; - tree1->t.tr1 = unoptim(tnode1(LTOI,INT,tree1->t.tr1, TNULL)); + tree->t.op = ITOP; + tree->t.tr1 = unoptim(tnode1(LTOI,INT,tree->t.tr1, TNULL)); case ITOP: - tree1->t.op = TIMES; + tree->t.op = TIMES; break; case MINUS: - if ((t = isconstant(tree1->t.tr2)) && (!uns(t) || tree1->t.type!=LONG) + if ((t = isconstant(tree->t.tr2)) && (!uns(t) || tree->t.type!=LONG) && (t->t.type!=INT || t->c.value!=(_INT)0100000)) { - tree1->t.op = PLUS; + tree->t.op = PLUS; if (t->t.type==DOUBLE) { /* PDP-11 FP representation */ t->f/*c*/.value ^= 0100000; @@ -96,86 +96,86 @@ union tree *optim(tree1) register union tree *tree1; { } break; } - op = tree1->t.op; + op = tree->t.op; dope = opdope1[op]; - if (dope&LVALUE && tree1->t.tr1->t.op==FSEL) - return(lvfield(tree1)); + if (dope&LVALUE && tree->t.tr1->t.op==FSEL) + return(lvfield(tree)); if ((dope&COMMUTE)!=0) { - d1 = tree1->t.type; - tree1 = acommute(tree1); - if (tree1->t.op == op) - tree1->t.type = d1; + d1 = tree->t.type; + tree = acommute(tree); + if (tree->t.op == op) + tree->t.type = d1; /* * PDP-11 special: * replace a&b by a ANDN ~ b. * This will be undone when in * truth-value context. */ - if (tree1->t.op!=AND) - return(tree1); + if (tree->t.op!=AND) + return(tree); /* * long & pos-int is simpler */ - if ((tree1->t.type==LONG || tree1->t.type==UNLONG) && tree1->t.tr2->t.op==ITOL - && (tree1->t.tr2->t.tr1->t.op==CON && tree1->t.tr2->t.tr1->c.value>=0 - || uns(tree1->t.tr2->t.tr1))) { - tree1->t.type = UNSIGN; - t = tree1->t.tr2; - tree1->t.tr2 = tree1->t.tr2->t.tr1; - t->t.tr1 = tree1; - tree1->t.tr1 = tnode1(LTOI, UNSIGN, tree1->t.tr1, TNULL); + if ((tree->t.type==LONG || tree->t.type==UNLONG) && tree->t.tr2->t.op==ITOL + && (tree->t.tr2->t.tr1->t.op==CON && tree->t.tr2->t.tr1->c.value>=0 + || uns(tree->t.tr2->t.tr1))) { + tree->t.type = UNSIGN; + t = tree->t.tr2; + tree->t.tr2 = tree->t.tr2->t.tr1; + t->t.tr1 = tree; + tree->t.tr1 = tnode1(LTOI, UNSIGN, tree->t.tr1, TNULL); return(optim(t)); } /* * Keep constants to the right */ - if ((tree1->t.tr1->t.op==ITOL && tree1->t.tr1->t.tr1->t.op==CON) - || tree1->t.tr1->t.op==LCON) { - t = tree1->t.tr1; - tree1->t.tr1 = tree1->t.tr2; - tree1->t.tr2 = t; + if ((tree->t.tr1->t.op==ITOL && tree->t.tr1->t.tr1->t.op==CON) + || tree->t.tr1->t.op==LCON) { + t = tree->t.tr1; + tree->t.tr1 = tree->t.tr2; + tree->t.tr2 = t; } - tree1->t.op = ANDN; + tree->t.op = ANDN; op = ANDN; - tree1->t.tr2 = tnode1(COMPL, tree1->t.tr2->t.type, tree1->t.tr2, TNULL); + tree->t.tr2 = tnode1(COMPL, tree->t.tr2->t.type, tree->t.tr2, TNULL); } again: - tree1->t.tr1 = optim(tree1->t.tr1); - tree1->t.tr2 = optim(tree1->t.tr2); - if (tree1->t.type == LONG || tree1->t.type==UNLONG) { - t = lconst1(tree1->t.op, tree1->t.tr1, tree1->t.tr2); + tree->t.tr1 = optim(tree->t.tr1); + tree->t.tr2 = optim(tree->t.tr2); + if (tree->t.type == LONG || tree->t.type==UNLONG) { + t = lconst(tree->t.op, tree->t.tr1, tree->t.tr2); if (t) return(t); } if ((dope&RELAT) != 0) { - if ((d1=degree(tree1->t.tr1)) < (d2=degree(tree1->t.tr2)) - || d1==d2 && tree1->t.tr1->t.op==NAME && tree1->t.tr2->t.op!=NAME) { - t = tree1->t.tr1; - tree1->t.tr1 = tree1->t.tr2; - tree1->t.tr2 = t; - tree1->t.op = maprel[op-EQUAL]; + if ((d1=degree(tree->t.tr1)) < (d2=degree(tree->t.tr2)) + || d1==d2 && tree->t.tr1->t.op==NAME && tree->t.tr2->t.op!=NAME) { + t = tree->t.tr1; + tree->t.tr1 = tree->t.tr2; + tree->t.tr2 = t; + tree->t.op = maprel[op-EQUAL]; } - if (tree1->t.tr1->t.type==CHAR && tree1->t.tr2->t.op==CON - && (dcalc(tree1->t.tr1, 0) <= 12 || tree1->t.tr1->t.op==STAR) - && tree1->t.tr2->c.value <= 127 && tree1->t.tr2->c.value >= 0) - tree1->t.tr2->t.type = CHAR; + if (tree->t.tr1->t.type==CHAR && tree->t.tr2->t.op==CON + && (dcalc(tree->t.tr1, 0) <= 12 || tree->t.tr1->t.op==STAR) + && tree->t.tr2->c.value <= 127 && tree->t.tr2->c.value >= 0) + tree->t.tr2->t.type = CHAR; } - d1 = max(degree(tree1->t.tr1), islong(tree1->t.type)); - d2 = max(degree(tree1->t.tr2), 0); + d1 = max(degree(tree->t.tr1), islong(tree->t.type)); + d2 = max(degree(tree->t.tr2), 0); switch (op) { /* * In assignment to fields, treat all-zero and all-1 specially. */ case FSELA: - if (tree1->t.tr2->t.op==CON && tree1->t.tr2->c.value==0) { - tree1->t.op = ASAND; - tree1->t.tr2->c.value = ~tree1->F.mask; - return(optim(tree1)); + if (tree->t.tr2->t.op==CON && tree->t.tr2->c.value==0) { + tree->t.op = ASAND; + tree->t.tr2->c.value = ~tree->F.mask; + return(optim(tree)); } - if (tree1->t.tr2->t.op==CON && tree1->F.mask==tree1->t.tr2->c.value) { - tree1->t.op = ASOR; - return(optim(tree1)); + if (tree->t.tr2->t.op==CON && tree->F.mask==tree->t.tr2->c.value) { + tree->t.op = ASOR; + return(optim(tree)); } case LTIMES: @@ -194,110 +194,110 @@ union tree *optim(tree1) register union tree *tree1; { case ULMOD: case ULASTIMES: case ULASDIV: - tree1->t.degree = 10; + tree->t.degree = 10; break; case ANDN: - if (isconstant(tree1->t.tr2) && tree1->t.tr2->c.value==0) { - return(tree1->t.tr1); + if (isconstant(tree->t.tr2) && tree->t.tr2->c.value==0) { + return(tree->t.tr1); } goto def; case CALL: - tree1->t.degree = 10; + tree->t.degree = 10; break; case QUEST: case COLON: - tree1->t.degree = max(d1, d2); + tree->t.degree = max(d1, d2); break; case PTOI: case DIVIDE: case ASDIV: case ASTIMES: - if (tree1->t.tr2->t.op==CON && tree1->t.tr2->c.value==1) { + if (tree->t.tr2->t.op==CON && tree->t.tr2->c.value==1) { if (op==PTOI) - return(optim(tnode1(LTOI,INT,paint(tree1->t.tr1,LONG), TNULL))); - return(paint(tree1->t.tr1, tree1->t.type)); + return(optim(tnode1(LTOI,INT,paint(tree->t.tr1,LONG), TNULL))); + return(paint(tree->t.tr1, tree->t.type)); } case MOD: case ASMOD: - if ((uns(tree1->t.tr1) || tree1->t.op==PTOI) && ispow2(tree1)) - return(pow2(tree1)); - if ((op==MOD||op==ASMOD) && tree1->t.type==DOUBLE) { + if ((uns(tree->t.tr1) || tree->t.op==PTOI) && ispow2(tree)) + return(pow2(tree)); + if ((op==MOD||op==ASMOD) && tree->t.type==DOUBLE) { error1("Floating %% not defined"); - tree1->t.type = INT; + tree->t.type = INT; } case ULSH: case ASULSH: d1 += 2 + regpanic; d2 += 2 + regpanic; panicposs++; - if (tree1->t.type==LONG || tree1->t.type==UNLONG) - return(hardlongs(tree1)); + if (tree->t.type==LONG || tree->t.type==UNLONG) + return(hardlongs(tree)); if ((op==MOD || op==DIVIDE || op==ASMOD || op==ASDIV) - && (uns(tree1->t.tr1) || uns(tree1->t.tr2)) - && (tree1->t.tr2->t.op!=CON || tree1->t.tr2->c.value<=1)) { + && (uns(tree->t.tr1) || uns(tree->t.tr2)) + && (tree->t.tr2->t.op!=CON || tree->t.tr2->c.value<=1)) { if (op>=ASDIV) { - tree1->t.op += ASUDIV - ASDIV; + tree->t.op += ASUDIV - ASDIV; } else - tree1->t.op += UDIV - DIVIDE; + tree->t.op += UDIV - DIVIDE; d1 = d2 = 10; } goto constant; case ASPLUS: case ASMINUS: - if (tree1->t.tr2->t.op==CON && tree1->t.tr2->c.value==0) - return(tree1->t.tr1); + if (tree->t.tr2->t.op==CON && tree->t.tr2->c.value==0) + return(tree->t.tr1); goto def; case LSHIFT: case RSHIFT: case ASRSH: case ASLSH: - if (tree1->t.tr2->t.op==CON && tree1->t.tr2->c.value==0) - return(paint(tree1->t.tr1, tree1->t.type)); + if (tree->t.tr2->t.op==CON && tree->t.tr2->c.value==0) + return(paint(tree->t.tr1, tree->t.type)); /* * PDP-11 special: turn right shifts into negative * left shifts */ - if (tree1->t.type == LONG || tree1->t.type==UNLONG) { + if (tree->t.type == LONG || tree->t.type==UNLONG) { d1++; d2++; } if (op==LSHIFT||op==ASLSH) goto constant; - if (tree1->t.tr2->t.op==CON && tree1->t.tr2->c.value==1 - && !uns(tree1->t.tr1) && !uns(tree1->t.tr2)) + if (tree->t.tr2->t.op==CON && tree->t.tr2->c.value==1 + && !uns(tree->t.tr1) && !uns(tree->t.tr2)) goto constant; op += (LSHIFT-RSHIFT); - tree1->t.op = op; - tree1->t.tr2 = tnode1(NEG, tree1->t.tr2->t.type, tree1->t.tr2, TNULL); - if (uns(tree1->t.tr1) || uns(tree1->t.tr2)) { - if (tree1->t.op==LSHIFT) - tree1->t.op = ULSH; - else if (tree1->t.op==ASLSH) - tree1->t.op = ASULSH; + tree->t.op = op; + tree->t.tr2 = tnode1(NEG, tree->t.tr2->t.type, tree->t.tr2, TNULL); + if (uns(tree->t.tr1) || uns(tree->t.tr2)) { + if (tree->t.op==LSHIFT) + tree->t.op = ULSH; + else if (tree->t.op==ASLSH) + tree->t.op = ASULSH; } goto again; constant: - if (tree1->t.tr1->t.op==CON && tree1->t.tr2->t.op==CON) { - _const(op, &tree1->t.tr1->c.value, tree1->t.tr2->c.value, tree1->t.type); - return(tree1->t.tr1); + if (tree->t.tr1->t.op==CON && tree->t.tr2->t.op==CON) { + _const(op, &tree->t.tr1->c.value, tree->t.tr2->c.value, tree->t.type); + return(tree->t.tr1); } def: default: if (dope&RELAT) { - if (tree1->t.tr1->t.type==LONG || tree1->t.tr1->t.type==UNLONG) /* long relations are a mess */ + if (tree->t.tr1->t.type==LONG || tree->t.tr1->t.type==UNLONG) /* long relations are a mess */ d1 = 10; - if (opdope1[tree1->t.tr1->t.op]&RELAT && tree1->t.tr2->t.op==CON - && tree1->t.tr2->c.value==0) { - tree1 = tree1->t.tr1; + if (opdope1[tree->t.tr1->t.op]&RELAT && tree->t.tr2->t.op==CON + && tree->t.tr2->c.value==0) { + tree = tree->t.tr1; switch(op) { case GREATEQ: return((union tree *)&cone); @@ -305,41 +305,41 @@ union tree *optim(tree1) register union tree *tree1; { return((union tree *)&czero); case LESSEQ: case EQUAL: - tree1->t.op = notrel[tree1->t.op-EQUAL]; + tree->t.op = notrel[tree->t.op-EQUAL]; } - return(tree1); + return(tree); } } - tree1->t.degree = d1==d2? d1+islong(tree1->t.type): max(d1, d2); + tree->t.degree = d1==d2? d1+islong(tree->t.type): max(d1, d2); break; } - return(tree1); + return(tree); } -union tree *unoptim(tree1) register union tree *tree1; { - /*fprintf(stderr, "unoptim %d", tree1->t.op); - if ((opdope1[tree1->t.op] & LEAF) == 0) - fprintf(stderr, " left %d", tree1->t.tr1->t.op); - if (opdope1[tree1->t.op] & BINARY) - fprintf(stderr, " right %d", tree1->t.tr2->t.op); +union tree *unoptim(tree) register union tree *tree; { + /*fprintf(stderr, "unoptim %d", tree->t.op); + if ((opdope1[tree->t.op] & LEAF) == 0) + fprintf(stderr, " left %d", tree->t.tr1->t.op); + if (opdope1[tree->t.op] & BINARY) + fprintf(stderr, " right %d", tree->t.tr2->t.op); fprintf(stderr, "\n");*/ register union tree *subtre, *p; - if (tree1==NULL) + if (tree==NULL) return(NULL); again: - if (tree1->t.op==AMPER && tree1->t.tr1->t.op==STAR) { - subtre = tree1->t.tr1->t.tr1; - subtre->t.type = tree1->t.type; + if (tree->t.op==AMPER && tree->t.tr1->t.op==STAR) { + subtre = tree->t.tr1->t.tr1; + subtre->t.type = tree->t.type; return(optim(subtre)); } - subtre = tree1->t.tr1 = optim(tree1->t.tr1); - switch (tree1->t.op) { + subtre = tree->t.tr1 = optim(tree->t.tr1); + switch (tree->t.op) { case INCAFT: case DECAFT: - if (tree1->t.type!=subtre->t.type) - paint(subtre, tree1->t.type); + if (tree->t.type!=subtre->t.type) + paint(subtre, tree->t.type); break; case ITOL: @@ -347,60 +347,60 @@ union tree *unoptim(tree1) register union tree *tree1; { subtre = getblk(sizeof(struct lconst)); subtre->t.op = LCON; subtre->t.type = LONG; - subtre->l.lvalue = tree1->t.tr1->c.value; + subtre->l.lvalue = tree->t.tr1->c.value; return(subtre); } break; case FTOI: - if (uns(tree1)) { - tree1->t.op = FTOL; - tree1->t.type = LONG; - tree1 = tnode1(LTOI, UNSIGN, tree1, TNULL); + if (uns(tree)) { + tree->t.op = FTOL; + tree->t.type = LONG; + tree = tnode1(LTOI, UNSIGN, tree, TNULL); } break; case LTOF: if (subtre->t.op==LCON) { - tree1 = getblk(sizeof(struct ftconst)); - tree1->t.op = FCON; - tree1->t.type = DOUBLE; - tree1->f/*c*/.value = isn1++; + tree = getblk(sizeof(struct ftconst)); + tree->t.op = FCON; + tree->t.type = DOUBLE; + tree->f/*c*/.value = isn1++; #ifdef pdp11 - tree1->f.fvalue = subtre->l.lvalue; + tree->f.fvalue = subtre->l.lvalue; #else - tree1->f.fvalue = fp_long_to_double(subtre->l.lvalue); + tree->f.fvalue = fp_long_to_double(subtre->l.lvalue); #endif - return(optim(tree1)); + return(optim(tree)); } if (subtre->t.type==UNLONG) - tree1->t.op = ULTOF; + tree->t.op = ULTOF; break; case ITOF: if (subtre->t.op==CON) { - tree1 = getblk(sizeof(struct ftconst)); - tree1->t.op = FCON; - tree1->t.type = DOUBLE; - tree1->f.value = isn1++; + tree = getblk(sizeof(struct ftconst)); + tree->t.op = FCON; + tree->t.type = DOUBLE; + tree->f.value = isn1++; #ifdef pdp11 if (uns(subtre)) - tree1->f.fvalue = (_UNSIGNED_INT)subtre->c.value; + tree->f.fvalue = (_UNSIGNED_INT)subtre->c.value; else - tree1->f.fvalue = subtre->c.value; + tree->f.fvalue = subtre->c.value; #else /* revisit the unsigned case */ if (uns(subtre)) - tree1->f.fvalue = fp_long_to_double((_LONG)(_UNSIGNED_INT)subtre->c.value); + tree->f.fvalue = fp_long_to_double((_LONG)(_UNSIGNED_INT)subtre->c.value); else - tree1->f.fvalue = fp_int_to_double(subtre->c.value); + tree->f.fvalue = fp_int_to_double(subtre->c.value); #endif - return(optim(tree1)); + return(optim(tree)); } if (uns(subtre)) { - tree1->t.tr1 = tnode1(ITOL, LONG, subtre, TNULL); - tree1->t.op = LTOF; - return(optim(tree1)); + tree->t.tr1 = tnode1(ITOL, LONG, subtre, TNULL); + tree->t.op = LTOF; + return(optim(tree)); } break; @@ -412,9 +412,9 @@ union tree *unoptim(tree1) register union tree *tree1; { char c; c = subtre->c.value; subtre->c.value = c; - subtre->t.type = tree1->t.type; + subtre->t.type = tree->t.type; return(subtre); - } else if (subtre->t.op==NAME && tree1->t.type==INT) { + } else if (subtre->t.op==NAME && tree->t.type==INT) { subtre->t.type = CHAR; return(subtre); } @@ -425,23 +425,23 @@ union tree *unoptim(tree1) register union tree *tree1; { case LCON: subtre->t.op = CON; - subtre->t.type = tree1->t.type; + subtre->t.type = tree->t.type; subtre->c.value = subtre->l.lvalue; return(subtre); case NAME: subtre->n.offset += 2; - subtre->t.type = tree1->t.type; + subtre->t.type = tree->t.type; return(subtre); case STAR: - subtre->t.type = tree1->t.type; - subtre->t.tr1->t.type = tree1->t.type+PTR; - subtre->t.tr1 = tnode1(PLUS, tree1->t.type, subtre->t.tr1, tconst1(2, INT)); + subtre->t.type = tree->t.type; + subtre->t.tr1->t.type = tree->t.type+PTR; + subtre->t.tr1 = tnode1(PLUS, tree->t.type, subtre->t.tr1, tconst(2, INT)); return(optim(subtre)); case ITOL: - return(paint(subtre->t.tr1, tree1->t.type)); + return(paint(subtre->t.tr1, tree->t.type)); case PLUS: case MINUS: @@ -449,76 +449,76 @@ union tree *unoptim(tree1) register union tree *tree1; { case ANDN: case OR: case EXOR: - subtre->t.tr2 = tnode1(LTOI, tree1->t.type, subtre->t.tr2, TNULL); + subtre->t.tr2 = tnode1(LTOI, tree->t.type, subtre->t.tr2, TNULL); case NEG: case COMPL: - subtre->t.tr1 = tnode1(LTOI, tree1->t.type, subtre->t.tr1, TNULL); - subtre->t.type = tree1->t.type; + subtre->t.tr1 = tnode1(LTOI, tree->t.type, subtre->t.tr1, TNULL); + subtre->t.type = tree->t.type; return(optim(subtre)); } break; case FSEL: - tree1->t.op = AND; - /* tree1->t.tr1 = tree1->t.tr2->t.tr1; - tree1->t.tr2->t.tr1 = subtre; - tree1->t.tr2->t.op = RSHIFT; - tree1->t.tr1->c.value = (1 << tree1->t.tr1->c.value) - 1;*/ - tree1->t.tr1 = tconst1((1 << ((struct FS *)tree1->t.tr2)->flen) - 1, INT); - tree1->t.tr2 = tnode1(RSHIFT, INT, subtre, tconst1(((struct FS *)tree1->t.tr2)->bitoffs, INT)); - return(optim(tree1)); + tree->t.op = AND; + /* tree->t.tr1 = tree->t.tr2->t.tr1; + tree->t.tr2->t.tr1 = subtre; + tree->t.tr2->t.op = RSHIFT; + tree->t.tr1->c.value = (1 << tree->t.tr1->c.value) - 1;*/ + tree->t.tr1 = tconst((1 << ((struct FS *)tree->t.tr2)->flen) - 1, INT); + tree->t.tr2 = tnode1(RSHIFT, INT, subtre, tconst(((struct FS *)tree->t.tr2)->bitoffs, INT)); + return(optim(tree)); case FSELR: - tree1->t.op = LSHIFT; - tree1->t.type = UNSIGN; - /* tree1->t.tr1 = tree1->t.tr2; - tree1->t.tr1->t.op = AND; - tree1->t.tr2 = tree1->t.tr2->t.tr2; - tree1->t.tr1->t.tr2 = subtre; - tree1->t.tr1->t.tr1->c.value = (1 << tree1->t.tr1->t.tr1->c.value) -1;*/ - tree1->t.tr1 = tnode1(AND, INT, tconst1((1 << ((struct FS *)tree1->t.tr2)->flen) - 1, INT), subtre); - tree1->t.tr2 = tconst1(((struct FS *)tree1->t.tr2)->bitoffs, INT); - return(optim(tree1)); + tree->t.op = LSHIFT; + tree->t.type = UNSIGN; + /* tree->t.tr1 = tree->t.tr2; + tree->t.tr1->t.op = AND; + tree->t.tr2 = tree->t.tr2->t.tr2; + tree->t.tr1->t.tr2 = subtre; + tree->t.tr1->t.tr1->c.value = (1 << tree->t.tr1->t.tr1->c.value) -1;*/ + tree->t.tr1 = tnode1(AND, INT, tconst((1 << ((struct FS *)tree->t.tr2)->flen) - 1, INT), subtre); + tree->t.tr2 = tconst(((struct FS *)tree->t.tr2)->bitoffs, INT); + return(optim(tree)); case AMPER: if (subtre->t.op==STAR) return(subtre->t.tr1); if (subtre->t.op==NAME && subtre->n.class == OFFS) { - p = tnode1(PLUS, tree1->t.type, subtre, tree1); - subtre->t.type = tree1->t.type; - tree1->t.op = CON; - tree1->t.type = INT; - tree1->t.degree = 0; - tree1->c.value = subtre->n.offset; + p = tnode1(PLUS, tree->t.type, subtre, tree); + subtre->t.type = tree->t.type; + tree->t.op = CON; + tree->t.type = INT; + tree->t.degree = 0; + tree->c.value = subtre->n.offset; subtre->n.class = REG; subtre->n.nloc = subtre->n.regno; subtre->n.offset = 0; return(optim(p)); } if (subtre->t.op==LOAD) { - tree1->t.tr1 = subtre->t.tr1; + tree->t.tr1 = subtre->t.tr1; goto again; } break; case STAR: if (subtre->t.op==AMPER) { - subtre->t.tr1->t.type = tree1->t.type; + subtre->t.tr1->t.type = tree->t.type; return(subtre->t.tr1); } - if (tree1->t.type==STRUCT) + if (tree->t.type==STRUCT) break; if (subtre->t.op==NAME && subtre->n.class==REG) { - subtre->t.type = tree1->t.type; + subtre->t.type = tree->t.type; subtre->n.class = OFFS; subtre->n.regno = subtre->n.nloc; return(subtre); } p = subtre->t.tr1; if ((subtre->t.op==INCAFT||subtre->t.op==DECBEF) - && tree1->t.type!=LONG && tree1->t.type!=UNLONG + && tree->t.type!=LONG && tree->t.type!=UNLONG && p->t.op==NAME && p->n.class==REG && p->t.type==subtre->t.type) { - p->t.type = tree1->t.type; + p->t.type = tree->t.type; p->t.op = subtre->t.op==INCAFT? AUTOI: AUTOD; return(p); } @@ -526,7 +526,7 @@ union tree *unoptim(tree1) register union tree *tree1; { if (subtre->t.tr2->t.op==CON) { p->n.offset += subtre->t.tr2->c.value; p->n.class = OFFS; - p->t.type = tree1->t.type; + p->t.type = tree->t.type; p->n.regno = p->n.nloc; return(p); } @@ -534,7 +534,7 @@ union tree *unoptim(tree1) register union tree *tree1; { subtre = subtre->t.tr2->t.tr1; subtre->n.class += XOFFS-EXTERN; subtre->n.regno = p->n.nloc; - subtre->t.type = tree1->t.type; + subtre->t.type = tree->t.type; return(subtre); } } @@ -542,7 +542,7 @@ union tree *unoptim(tree1) register union tree *tree1; { && subtre->t.tr2->t.op==CON) { p->n.offset -= subtre->t.tr2->c.value; p->n.class = OFFS; - p->t.type = tree1->t.type; + p->t.type = tree->t.type; p->n.regno = p->n.nloc; return(p); } @@ -550,18 +550,18 @@ union tree *unoptim(tree1) register union tree *tree1; { case EXCLA: if ((opdope1[subtre->t.op]&RELAT)==0) break; - tree1 = subtre; - tree1->t.op = notrel[tree1->t.op-EQUAL]; + tree = subtre; + tree->t.op = notrel[tree->t.op-EQUAL]; break; case COMPL: - if (tree1->t.type==CHAR) - tree1->t.type = INT; - if (tree1->t.op == subtre->t.op) - return(paint(subtre->t.tr1, tree1->t.type)); + if (tree->t.type==CHAR) + tree->t.type = INT; + if (tree->t.op == subtre->t.op) + return(paint(subtre->t.tr1, tree->t.type)); if (subtre->t.op==CON) { subtre->c.value = ~subtre->c.value; - return(paint(subtre, tree1->t.type)); + return(paint(subtre, tree->t.type)); } if (subtre->t.op==LCON) { subtre->l.lvalue = ~subtre->l.lvalue; @@ -569,49 +569,49 @@ union tree *unoptim(tree1) register union tree *tree1; { } if (subtre->t.op==ITOL) { if (subtre->t.tr1->t.op==CON) { - tree1 = getblk(sizeof(struct lconst)); - tree1->t.op = LCON; - tree1->t.type = LONG; + tree = getblk(sizeof(struct lconst)); + tree->t.op = LCON; + tree->t.type = LONG; if (uns(subtre->t.tr1)) - tree1->l.lvalue = ~(_LONG)(_UNSIGNED_INT) + tree->l.lvalue = ~(_LONG)(_UNSIGNED_INT) subtre->t.tr1->c.value; else - tree1->l.lvalue = + tree->l.lvalue = ~subtre->t.tr1->c.value; - return(tree1); + return(tree); } if (uns(subtre->t.tr1)) break; - subtre->t.op = tree1->t.op; + subtre->t.op = tree->t.op; subtre->t.type = subtre->t.tr1->t.type; - tree1->t.op = ITOL; - tree1->t.type = LONG; + tree->t.op = ITOL; + tree->t.type = LONG; goto again; } case NEG: - if (tree1->t.type==CHAR) - tree1->t.type = INT; - if (tree1->t.op==subtre->t.op) - return(paint(subtre->t.tr1, tree1->t.type)); + if (tree->t.type==CHAR) + tree->t.type = INT; + if (tree->t.op==subtre->t.op) + return(paint(subtre->t.tr1, tree->t.type)); if (subtre->t.op==CON) { subtre->c.value = -subtre->c.value; - return(paint(subtre, tree1->t.type)); + return(paint(subtre, tree->t.type)); } if (subtre->t.op==LCON) { subtre->l.lvalue = -subtre->l.lvalue; return(subtre); } if (subtre->t.op==ITOL && subtre->t.tr1->t.op==CON) { - tree1 = getblk(sizeof(struct lconst)); - tree1->t.op = LCON; - tree1->t.type = LONG; + tree = getblk(sizeof(struct lconst)); + tree->t.op = LCON; + tree->t.type = LONG; if (uns(subtre->t.tr1)) - tree1->l.lvalue = -(_LONG)(_UNSIGNED_INT) + tree->l.lvalue = -(_LONG)(_UNSIGNED_INT) subtre->t.tr1->c.value; else - tree1->l.lvalue = -subtre->t.tr1->c.value; - return(tree1); + tree->l.lvalue = -subtre->t.tr1->c.value; + return(tree); } /* * PDP-11 FP negation @@ -634,9 +634,9 @@ union tree *unoptim(tree1) register union tree *tree1; { return(subtre); } } - if ((opdope1[tree1->t.op]&LEAF)==0) - tree1->t.degree = max(islong(tree1->t.type), degree(subtre)); - return(tree1); + if ((opdope1[tree->t.op]&LEAF)==0) + tree->t.degree = max(islong(tree->t.type), degree(subtre)); + return(tree); } /* @@ -689,8 +689,8 @@ union tree *lvfield(t) register union tree *t; { /*t=ASANDN(mos,FSELR(arg,COMMA(flen,bitoffs)))*/ t1 = t1->t.tr2; /*t1=COMMA(flen,bitoffs)*/ - /*t1 = tnode1(COMMA, INT, tconst1(t1->t.tr1->c.value, INT), - tconst1(t1->t.tr2->c.value, INT));*/ + /*t1 = tnode1(COMMA, INT, tconst(t1->t.tr1->c.value, INT), + tconst(t1->t.tr2->c.value, INT));*/ /*t1=COMMA(flen,bitoffs)*/ return(optim(tnode1(FSELT, UNSIGN, t, t1))); @@ -709,7 +709,7 @@ struct acl { }; #endif -union tree *acommute(tree1) register union tree *tree1; { +union tree *acommute(tree) register union tree *tree; { struct acl acl; int d, i, op, flt, d1, type; register union tree *t1, **t2; @@ -717,10 +717,10 @@ union tree *acommute(tree1) register union tree *tree1; { acl.nextl = 0; acl.nextn = 0; - op = tree1->t.op; - type = tree1->t.type; - flt = isfloat(tree1); - insert(op, tree1, &acl); + op = tree->t.op; + type = tree->t.type; + flt = isfloat(tree); + insert(op, tree, &acl); acl.nextl--; t2 = &acl.llist[acl.nextl]; if (!flt) { @@ -732,7 +732,7 @@ union tree *acommute(tree1) register union tree *tree1; { t2--; _const(op, &t2[0]->c.value, t2[1]->c.value, d); t2[0]->t.type = d; - } else if (t = lconst1(op, t2[-1], t2[0])) { + } else if (t = lconst(op, t2[-1], t2[0])) { acl.nextl--; t2--; t2[0] = t; @@ -748,8 +748,8 @@ union tree *acommute(tree1) register union tree *tree1; { } if (acl.nextl <= 0) { if ((*t2)->t.type==CHAR || (*t2)->t.type==UNCHAR) - *t2 = tnode1(LOAD, tree1->t.type, *t2, TNULL); - (*t2)->t.type = tree1->t.type; + *t2 = tnode1(LOAD, tree->t.type, *t2, TNULL); + (*t2)->t.type = tree->t.type; return(*t2); } /* subsume constant in "&x+c" */ @@ -771,16 +771,16 @@ union tree *acommute(tree1) register union tree *tree1; { if (op==TIMES && t1->c.value==1 && acl.nextl>0) if (--acl.nextl <= 0) { t1 = acl.llist[0]; - if (uns(tree1)) - paint(t1, tree1->t.type); + if (uns(tree)) + paint(t1, tree->t.type); return(t1); } } } if (op==PLUS && !flt) distrib(&acl); - tree1 = *(t2 = &acl.llist[0]); - d = max(degree(tree1), islong(tree1->t.type)); + tree = *(t2 = &acl.llist[0]); + d = max(degree(tree), islong(tree->t.type)); if (op==TIMES && !flt) { d += regpanic+1; panicposs++; @@ -798,25 +798,25 @@ union tree *acommute(tree1) register union tree *tree1; { d1 = t->t.degree; } t1->t.degree = d = d==d1? d+islong(t1->t.type): max(d, d1); - t1->t.tr1 = tree1; - tree1 = t1; - if (tree1->t.type==LONG || tree1->t.type==UNLONG) { - if (tree1->t.op==TIMES) - tree1 = hardlongs(tree1); - else if (tree1->t.op==PLUS && (t = isconstant(tree1->t.tr1)) + t1->t.tr1 = tree; + tree = t1; + if (tree->t.type==LONG || tree->t.type==UNLONG) { + if (tree->t.op==TIMES) + tree = hardlongs(tree); + else if (tree->t.op==PLUS && (t = isconstant(tree->t.tr1)) && t->c.value < 0 && !uns(t)) { - tree1->t.op = MINUS; + tree->t.op = MINUS; t->c.value = - t->c.value; - t = tree1->t.tr1; - tree1->t.tr1 = tree1->t.tr2; - tree1->t.tr2 = t; + t = tree->t.tr1; + tree->t.tr1 = tree->t.tr2; + tree->t.tr2 = t; } } } - if (tree1->t.op==TIMES && ispow2(tree1)) - tree1->t.degree = max(degree(tree1->t.tr1), islong(tree1->t.type)); - paint(tree1, type); - return(tree1); + if (tree->t.op==TIMES && ispow2(tree)) + tree->t.degree = max(degree(tree->t.tr1), islong(tree->t.type)); + paint(tree, type); + return(tree); } int sideeffects(tp) register union tree *tp; { @@ -1017,10 +1017,10 @@ void _const(op, vp, v, type) int op; register _INT *vp; register _INT v; int typ *vp &= ~ v; return; } - error1("C error1: const"); + error1("C error: const"); } -union tree *lconst1(op, lp, rp) int op; register union tree *lp; register union tree *rp; { +union tree *lconst(op, lp, rp) int op; register union tree *lp; register union tree *rp; { _UNSIGNED_LONG l, r; if (lp->t.op==LCON) @@ -1110,48 +1110,48 @@ union tree *lconst1(op, lp, rp) int op; register union tree *lp; register union return(lp); } -void insert(op, tree1, list) int op; register union tree *tree1; register struct acl *list; { +void insert(op, tree, list) int op; register union tree *tree; register struct acl *list; { register int d; int d1, i; union tree *t; ins: - if (tree1->t.op != op) - tree1 = optim(tree1); - if (tree1->t.op == op && list->nextn < LSTSIZ-2) { - list->nlist[list->nextn++] = tree1; - insert(op, tree1->t.tr1, list); - insert(op, tree1->t.tr2, list); + if (tree->t.op != op) + tree = optim(tree); + if (tree->t.op == op && list->nextn < LSTSIZ-2) { + list->nlist[list->nextn++] = tree; + insert(op, tree->t.tr1, list); + insert(op, tree->t.tr2, list); return; } - if (!isfloat(tree1)) { + if (!isfloat(tree)) { /* c1*(x+c2) -> c1*x+c1*c2 */ - if ((tree1->t.op==TIMES||tree1->t.op==LSHIFT) - && tree1->t.tr2->t.op==CON && tree1->t.tr2->c.value>0 - && tree1->t.tr1->t.op==PLUS && tree1->t.tr1->t.tr2->t.op==CON) { - d = tree1->t.tr2->c.value; - if (tree1->t.op==TIMES) - tree1->t.tr2->c.value *= tree1->t.tr1->t.tr2->c.value; + if ((tree->t.op==TIMES||tree->t.op==LSHIFT) + && tree->t.tr2->t.op==CON && tree->t.tr2->c.value>0 + && tree->t.tr1->t.op==PLUS && tree->t.tr1->t.tr2->t.op==CON) { + d = tree->t.tr2->c.value; + if (tree->t.op==TIMES) + tree->t.tr2->c.value *= tree->t.tr1->t.tr2->c.value; else - tree1->t.tr2->c.value = tree1->t.tr1->t.tr2->c.value << d; - tree1->t.tr1->t.tr2->c.value = d; - tree1->t.tr1->t.op = tree1->t.op; - tree1->t.op = PLUS; - tree1 = optim(tree1); + tree->t.tr2->c.value = tree->t.tr1->t.tr2->c.value << d; + tree->t.tr1->t.tr2->c.value = d; + tree->t.tr1->t.op = tree->t.op; + tree->t.op = PLUS; + tree = optim(tree); if (op==PLUS) goto ins; } } - d = degree(tree1); + d = degree(tree); for (i=0; inextl; i++) { if ((d1=degree(list->llist[i]))llist[i]; - list->llist[i] = tree1; - tree1 = t; + list->llist[i] = tree; + tree = t; d = d1; } } - list->llist[list->nextl++] = tree1; + list->llist[list->nextl++] = tree; } union tree *tnode1(op, type, tr1, tr2) int op; int type; union tree *tr1; union tree *tr2; { @@ -1169,7 +1169,7 @@ union tree *tnode1(op, type, tr1, tr2) int op; int type; union tree *tr1; union return(p); } -union tree *tconst1(val, type) int val; int type; { +union tree *tconst(val, type) int val; int type; { register union tree *p; p = getblk(sizeof(struct tconst)); @@ -1246,7 +1246,7 @@ union tree *hardlongs(t) register union tree *t; { } /* - * Is tree1 of unsigned type? + * Is tree of unsigned type? */ int uns(tp) union tree *tp; { register int t; diff --git a/c13.c b/c13.c index da40457..aadc709 100644 --- a/c13.c +++ b/c13.c @@ -115,15 +115,15 @@ int opdope1[] = { 036000, /* mcall */ 000000, /* goto */ 000000, /* jump cond */ - 000000, /* branch1 cond */ + 000000, /* branch cond */ 000400, /* set nregs */ 000000, /* load */ 030001, /* ptoi1 */ 000000, /* (108) */ 000000, /* int->char */ 000000, /* force r0 (110) */ - 000000, /* branch1 */ - 000000, /* label1 */ + 000000, /* branch */ + 000000, /* label */ 000000, /* nlabel */ 000000, /* rlabel */ 000000, /* structure assign */ @@ -248,15 +248,15 @@ char *opntab[] = { "mcall", "goto", "jump cond", - "branch1 cond", + "branch cond", "set nregs", "load value", "ptr->integer", 0, "int->char", "force register", /* 110 */ - "branch1", - "label1", + "branch", + "label", "nlabel", "rlabel", "=structure", diff --git a/unify01.sed b/unify01.sed index c736fe6..cabb2a3 100644 --- a/unify01.sed +++ b/unify01.sed @@ -6,10 +6,11 @@ s/[^A-Za-z0-9_]\+/@&@/g s/@\(TNULL\)[01]@/@\1@/g s/@\(union@[ ]*@tree\)[01]@/@\1@/g s/@\(struct@[ ]*@tnode\)[01]@/@\1@/g -s/@\(struct@[ ]*@tconst\)[01]@/@\1@/g -s/@\(struct@[ ]*@lconst\)[01]@/@\1@/g -s/@\(struct@[ ]*@ftconst\)[01]@/@\1@/g -#s/@\(isn\)[01]*/@\1@/g +s/@\(struct@[ ]*@nnode\)[01]@/@\1@/g +s/@\(struct@[ ]*@xnode\)[01]@/@\1@/g +s/@\(struct@[ ]*@cnode\)[01]@/@\1@/g +s/@\(struct@[ ]*@lnode\)[01]@/@\1@/g +s/@\(struct@[ ]*@fnode\)[01]@/@\1@/g s/@//g s/ATSIGN/@/g diff --git a/uniqify0.sed b/uniqify0.sed index fbfbb3b..76a952c 100644 --- a/uniqify0.sed +++ b/uniqify0.sed @@ -3,28 +3,30 @@ s/^/@/ s/$/@/ s/[^A-Za-z0-9_]\+/@&@/g -s/@opdope@/@opdope0@/g -s/@rcexpr@/@rcexpr0@/g -s/@error@/@error0@/g -s/@pswitch@/@pswitch0@/g -s/@cbranch@/@cbranch0@/g -s/@label@/@label0@/g -s/@branch@/@branch0@/g -s/@werror@/@werror0@/g -s/@decref@/@decref0@/g -s/@incref@/@incref0@/g -s/@isn@/@isn0@/g -s/@tnode@/@tnode0@/g -s/@funcblk@/@funcblk0@/g -s/@cp@/@cp0@/g -s/@tree@/@tree0@/g -s/@xprtype@/@xprtype0@/g -s/@TNULL@/@TNULL0@/g -s/@cnode@/@tconst0@/g -s/@lnode@/@lconst0@/g -s/@fnode@/@ftconst0@/g +# functions +s/@\(rcexpr\)@\([ ]*(\)/@\10@\2/g +s/@\(error\)@\([ ]*(\)/@\10@\2/g +s/@\(pswitch\)@\([ ]*(\)/@\10@\2/g +s/@\(cbranch\)@\([ ]*(\)/@\10@\2/g +s/@\(label\)@\([ ]*(\)/@\10@\2/g +s/@\(branch\)@\([ ]*(\)/@\10@\2/g +s/@\(werror\)@\([ ]*(\)/@\10@\2/g +s/@\(decref\)@\([ ]*(\)/@\10@\2/g +s/@\(incref\)@\([ ]*(\)/@\10@\2/g +# variables +s/@\(opdope\)@/@\10@/g +s/@\(isn\)@/@\10@/g +# values +s/@\(TNULL\)@/@\10@/g + +# types +s/@\(struct@[ ]*@tnode\)@/@\10@/g +s/@\(struct@[ ]*@cnode\)@/@\10@/g +s/@\(struct@[ ]*@lnode\)@/@\10@/g +s/@\(struct@[ ]*@fnode\)@/@\10@/g +s/@\(union@[ ]*@tree\)@/@\10@/g s/@//g s/ATSIGN/@/g diff --git a/uniqify1.sed b/uniqify1.sed index de7c3af..b9bf185 100644 --- a/uniqify1.sed +++ b/uniqify1.sed @@ -3,26 +3,32 @@ s/^/@/ s/$/@/ s/[^A-Za-z0-9_]\+/@&@/g -s/@opdope@/@opdope1@/g -s/@rcexpr@/@rcexpr1@/g -s/@error@/@error1@/g -s/@pswitch@/@pswitch1@/g -s/@cbranch@/@cbranch1@/g -s/@label@/@label1@/g -s/@branch@/@branch1@/g -s/@werror@/@werror1@/g -s/@decref@/@decref1@/g -s/@incref@/@incref1@/g -s/@isn@/@isn1@/g -s/@tnode@/@tnode1@/g -s/@funcblk@/@funcblk1@/g -s/@cp@/@cp1@/g -s/@tree@/@tree1@/g -s/@xprtype@/@xprtype1@/g -s/@TNULL@/@TNULL1@/g -s/@tconst@/@tconst1@/g -s/@lconst@/@lconst1@/g -s/@ftconst@/@ftconst1@/g +# functions +s/@\(rcexpr\)@\([ ]*(\)/@\11@\2/g +s/@\(error\)@\([ ]*(\)/@\11@\2/g +s/@\(pswitch\)@\([ ]*(\)/@\11@\2/g +s/@\(cbranch\)@\([ ]*(\)/@\11@\2/g +s/@\(label\)@\([ ]*(\)/@\11@\2/g +s/@\(branch\)@\([ ]*(\)/@\11@\2/g +s/@\(werror\)@\([ ]*(\)/@\11@\2/g +s/@\(decref\)@\([ ]*(\)/@\11@\2/g +s/@\(incref\)@\([ ]*(\)/@\11@\2/g + +# variables +s/@\(opdope\)@/@\11@/g +s/@\(isn\)@/@\11@/g + +# values +s/@\(TNULL\)@/@\11@/g + +# types +s/@\(struct@[ ]*@tnode\)@/@\11@/g +s/@\(struct@[ ]*@\)tname@/@\1nnode1@/g +s/@\(struct@[ ]*@\)xtname@/@\1xnode1@/g +s/@\(struct@[ ]*@\)tconst@/@\1cnode1@/g +s/@\(struct@[ ]*@\)lconst@/@\1lnode1@/g +s/@\(struct@[ ]*@\)ftconst@/@\1fnode1@/g +s/@\(union@[ ]*@tree\)@/@\11@/g s/@//g s/ATSIGN/@/g -- 2.34.1