Actually unify union tree0 with union tree1, move tree definitions into ccom.h
authorNick Downing <downing.nick@gmail.com>
Fri, 10 Feb 2017 09:34:04 +0000 (20:34 +1100)
committerNick Downing <downing.nick@gmail.com>
Fri, 10 Feb 2017 09:34:22 +0000 (20:34 +1100)
12 files changed:
c0.h
c00.c
c01.c
c02.c
c03.c
c04.c
c1.h
c10.c
c11.c
c12.c
ccom.h
unify01.sed [new file with mode: 0644]

diff --git a/c0.h b/c0.h
index 497f36b..bd90c26 100644 (file)
--- a/c0.h
+++ b/c0.h
@@ -92,69 +92,6 @@ union str {
        struct nmlist P;
 };
 
-/*
- * Structure of tree0 nodes for operators
- */
-struct tnode0 {
-       int     op;             /* operator */
-       int     type;           /* data type */
-       int     *subsp;         /* subscript list (for arrays) */
-       union   str *strp;      /* structure description for structs */
-       union   tree0 *tr1;     /* left operand */
-       union   tree0 *tr2;     /* right operand */
-};
-
-/*
- * Tree node for constants
- */
-struct tconst0 {
-       int     op;
-       int     type;
-       int     *subsp;
-       union   str *strp;
-       _INT    value;
-};
-
-/*
- * Tree node for long constants
- */
-struct lconst0 {
-       int     op;
-       int     type;
-       int     *subsp;
-       union   str *strp;
-       _LONG   lvalue;
-};
-
-/*
- * tree0 node for floating
- * constants
- */
-struct ftconst0 {
-       int     op;
-       int     type;
-       int     *subsp;
-       union   str *strp;
-       char    *cstr;
-};
-
-/*
- * All possibilities for tree0 nodes
- */
-union tree0 {
-       struct  tnode0 t;
-       struct  tconst0 c;
-       struct  lconst0 l;
-       struct  ftconst0 f;
- /*    struct  nmlist n;*/
- /* n occurs as tr1 of a NAME node, points into symbol table */
- /* we will just cast tr1 to "struct nmlist *" in that particular case */
- /*    struct  FS fld;*/
- /* fld occurs as tr2 of an FSEL node, points into structure description */
- /* we will just cast tr2 to "struct FS *" in that particular case */
-};
-
-
 /*
  * Place used to keep dimensions
  * during declarations
@@ -164,8 +101,6 @@ struct      tdim {
        int     dimens[5];
 };
 
-#define        TNULL0  (union tree0 *)NULL
-
 extern char cvtab[4][4];
 extern char filename[MAXPATHLEN]; /* Nick */
 extern int opdope0[];
@@ -173,7 +108,7 @@ extern char ctab[];
 extern char symbuf[MAXCPS+2];
 extern struct nmlist   *hshtab[HSHSIZ];
 extern int kwhash[(HSHSIZ+LNBPW-1)/LNBPW];
-extern union tree0 **cp0;
+extern union tree **cp0;
 extern int isn0;
 extern struct swtab swtab[SWSIZ];
 extern int unscflg;
@@ -213,7 +148,7 @@ extern FILE *sbufp;
 #endif
 extern int regvar;
 extern int bitoffs;
-extern struct tnode0 funcblk0;
+extern struct tnode funcblk0;
 extern char cvntab[];
 extern char numbuf[64];
 extern struct nmlist **memlist;
@@ -308,33 +243,33 @@ void putstr __P((int lab, register int max));
 void cntstr __P((void));
 int getcc __P((void));
 int mapch __P((int ac));
-union tree0 *tree0 __P((/*int eflag*/));
-union tree0 *xprtype0 __P((void));
+union tree *tree0 __P((/*int eflag*/));
+union tree *xprtype0 __P((void));
 char *copnum __P((int len));
 
 /* c01.c */
 void build __P((int op));
-void structident __P((register union tree0 *p1, register union tree0 *p2));
-union tree0 *convert __P((union tree0 *p, int t, int cvn, int len));
-void setype __P((register union tree0 *p, register int t, register union tree0 *newp));
-union tree0 *chkfun __P((register union tree0 *p));
-union tree0 *disarray __P((register union tree0 *p));
-void chkw __P((union tree0 *p, int okt));
+void structident __P((register union tree *p1, register union tree *p2));
+union tree *convert __P((union tree *p, int t, int cvn, int len));
+void setype __P((register union tree *p, register int t, register union tree *newp));
+union tree *chkfun __P((register union tree *p));
+union tree *disarray __P((register union tree *p));
+void chkw __P((union tree *p, int okt));
 int lintyp __P((int t));
 void werror0 __P((char *s, ...));
 void error0 __P((char *s, ...));
-union tree0 *block __P((int op, int t, int *subs, union str *str, union tree0 *p1, union tree0 *p2));
-union tree0 *nblock __P((register struct nmlist *ds));
-union tree0 *cblock __P((int v));
-union tree0 *fblock __P((int t, char *string));
+union tree *block __P((int op, int t, int *subs, union str *str, union tree *p1, union tree *p2));
+union tree *nblock __P((register struct nmlist *ds));
+union tree *cblock __P((int v));
+union tree *fblock __P((int t, char *string));
 char *Tblock __P((int n));
 char *starttree __P((void));
 void endtree __P((char *tp));
 char *Dblock __P((int n));
-void chklval __P((register union tree0 *p));
-int fold __P((int op, register union tree0 *p1, union tree0 *p2));
+void chklval __P((register union tree *p));
+int fold __P((int op, register union tree *p1, union tree *p2));
 int conexp __P((void));
-void assignop __P((int op, register union tree0 *p1, register union tree0 *p2));
+void assignop __P((int op, register union tree *p1, register union tree *p2));
 struct nmlist *gentemp __P((int type));
 
 /* c02.c */
@@ -345,7 +280,7 @@ void strinit __P((struct nmlist *np, int sclass));
 void setinit __P((register struct nmlist *np));
 void statement __P((void));
 int forstmt __P((void));
-union tree0 *pexpr __P((/*int eflag*/));
+union tree *pexpr __P((/*int eflag*/));
 void pswitch0 __P((void));
 void funchead __P((void));
 void blockhead __P((void));
@@ -371,14 +306,14 @@ int goodreg __P((struct nmlist *hp));
 /* c04.c */
 int decref0 __P((register int t));
 int incref0 __P((register int t));
-void cbranch0 __P((union tree0 *t, int lbl, int cond));
-void rcexpr0 __P((register union tree0 *tp));
-void treeout __P((register union tree0 *tp, int isstruct));
+void cbranch0 __P((union tree *t, int lbl, int cond));
+void rcexpr0 __P((register union tree *tp));
+void treeout __P((register union tree *tp, int isstruct));
 void branch0 __P((int lab));
 void label0 __P((int l));
-int plength __P((register union tree0 *p));
-int length __P((union tree0 *cs));
-int rlength __P((union tree0 *cs));
+int plength __P((register union tree *p));
+int length __P((union tree *cs));
+int rlength __P((union tree *cs));
 int simplegoto __P((void));
 int nextchar __P((void));
 int spnextchar __P((void));
diff --git a/c00.c b/c00.c
index 7d51cb1..497b1dd 100644 (file)
--- a/c00.c
+++ b/c00.c
@@ -16,7 +16,7 @@
 int    isn0    = 1;
 int    peeksym = -1;
 int    line    = 1;
-struct tnode0  funcblk0 = { NAME };
+struct tnode   funcblk0 = { NAME };
 
 struct kwtab kwtab[] = {
        {"int",         INT},
@@ -52,8 +52,8 @@ struct kwtab kwtab[] = {
        {0,             0}
 };
 
-union  tree0 *cmst[CMSIZ];
-union  tree0 **cp0 = cmst;
+union  tree *cmst[CMSIZ];
+union  tree **cp0 = cmst;
 int    Wflag;                  /* print warning messages */
 
 #if 0
@@ -614,13 +614,13 @@ loop:
  * "," or ":" because those delimiters are special
  * in initializer (and some other) expressions.
  */
-union tree0 *tree0(/*eflag*/) /*int eflag;*/ {
+union tree *tree0(/*eflag*/) /*int eflag;*/ {
        int *op, opst[SSIZE], *pp, prst[SSIZE];
        register int andflg, o;
        register struct nmlist *cs;
        int p, ps, os, xo = 0, *xop;
        /*char *svtree;*/
-       static struct tconst0 garbage = { CON, INT, (int *)NULL, (union str *)NULL, 0 };
+       static struct tconst garbage = { CON, INT, (int *)NULL, (union str *)NULL, 0 };
 
        /*svtree = starttree();*/
        op = opst;
@@ -658,7 +658,7 @@ advanc:
                goto tand;
 
        case LCON:
-               *cp0 = (union tree0 *)Tblock(sizeof(struct lconst0));
+               *cp0 = (union tree *)Tblock(sizeof(struct lconst));
                (*cp0)->l.op = LCON;
                (*cp0)->l.type = LONG;
                (*cp0)->l.lvalue = lcval;
@@ -702,7 +702,7 @@ advanc:
                cs->hclass = STATIC;
                cs->hoffset = cval;
                *cp0++ = block(NAME, unscflg? ARRAY+UNCHAR:ARRAY+CHAR, &nchstr,
-                 (union str *)NULL, (union tree0 *)cs, TNULL0);
+                 (union str *)NULL, (union tree *)cs, TNULL);
 
        tand:
                if(cp0>=cmst+CMSIZ) {
@@ -861,7 +861,7 @@ opon1:
 
        case MCALL:
                *cp0++ = block(NULLOP0, INT, (int *)NULL,
-                 (union str *)NULL, TNULL0, TNULL0);
+                 (union str *)NULL, TNULL, TNULL);
                os = CALL;
                break;
 
@@ -891,13 +891,13 @@ syntax:
        errflush(o);
        /*if (eflag)
                endtree(svtree);*/
-       return((union tree0 *) &garbage);
+       return((union tree *) &garbage);
 }
 
-union tree0 *xprtype0() {
+union tree *xprtype0() {
        struct nmlist typer, absname;
        int sc;
-       register union tree0 **scp;
+       register union tree **scp;
 
        scp = cp0;
        sc = DEFXTRN;           /* will cause error0 if class mentioned */
@@ -910,7 +910,7 @@ union tree0 *xprtype0() {
        decl1(sc, &typer, 0, &absname);
        cp0 = scp;
        return(block(ETYPE, absname.htype, absname.hsubsp,
-          absname.hstrp, TNULL0, TNULL0));
+          absname.hstrp, TNULL, TNULL));
 }
 
 char *copnum(len) int len; {
diff --git a/c01.c b/c01.c
index 6defe60..a5bc765 100644 (file)
--- a/c01.c
+++ b/c01.c
@@ -24,7 +24,7 @@
 void build(op) int op; {
        register int t1;
        int t2, t;
-       register union tree0 *p1, *p2, *p3;
+       register union tree *p1, *p2, *p3;
        int dope, leftc, cvn, pcvn;
 
        /*
@@ -74,7 +74,7 @@ void build(op) int op; {
                        error0("Disallowed conversion");
                if (p1->t.type==UNCHAR) {
                        *cp0++ = block(ETYPE, UNSIGN, (int *)NULL, (union str *)NULL,
-                          TNULL0, TNULL0);
+                          TNULL, TNULL);
                        *cp0++ = p2;
                        build(CAST);
                        *cp0++ = cblock(0377);
@@ -150,12 +150,12 @@ void build(op) int op; {
        case STAR:
                if ((t1&XTYPE) == FUNC)
                        error0("Illegal indirection");
-               *cp0++ = block(STAR, decref0(t1), p1->t.subsp, p1->t.strp, p1, TNULL0);
+               *cp0++ = 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,TNULL0);
+                       *cp0++ = block(op,incref0(p1->t.type),p1->t.subsp,p1->t.strp,p1,TNULL);
                        return;
                }
                error0("Illegal lvalue");
@@ -198,10 +198,10 @@ void build(op) int op; {
                if (((struct nmlist *)p2->t.tr1)->hflag&FFIELD)
 #if 1
                        cp0[-1] = block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, 
-                           cp0[-1], (union tree0 *)((struct nmlist *)p2->t.tr1)->hstrp);
+                           cp0[-1], (union tree *)((struct nmlist *)p2->t.tr1)->hstrp);
 #else
                        *cp0++ = block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, 
-                           *--cp0, (union tree0 *)((struct nmlist *)p2->t.tr1)->hstrp);
+                           *--cp0, (union tree *)((struct nmlist *)p2->t.tr1)->hstrp);
 #endif
                return;
        }
@@ -220,8 +220,8 @@ void build(op) int op; {
                        t1 = DOUBLE;
                else if (op==FTOI)
                        t1 = INT;
-               if (!fold(op, p1, (union tree0 *)NULL))
-                       *cp0++ = block(op, t1, p1->t.subsp, p1->t.strp, p1,TNULL0);
+               if (!fold(op, p1, (union tree *)NULL))
+                       *cp0++ = block(op, t1, p1->t.subsp, p1->t.strp, p1,TNULL);
                return;
        }
        cvn = 0;
@@ -330,8 +330,8 @@ void build(op) int op; {
                cvn = 0;
                if (op==MINUS) {
                        pcvn++;
-                       p1 = block(ITOL, LONG, (int *)NULL, (union str *)NULL, p1, TNULL0);
-                       p2 = block(ITOL, LONG, (int *)NULL, (union str *)NULL, p2, TNULL0);
+                       p1 = block(ITOL, LONG, (int *)NULL, (union str *)NULL, p1, TNULL);
+                       p2 = block(ITOL, LONG, (int *)NULL, (union str *)NULL, p2, TNULL);
                        t = LONG;
                } else {
                        if (t1!=t2 || (t1!=(PTR+CHAR) && t1!=(PTR+UNCHAR)))
@@ -370,7 +370,7 @@ void build(op) int op; {
                        p2->t.strp = p1->t.strp;
                }
                if (t==INT && p1->t.type==CHAR)
-                       p2 = block(ITOC, INT, (int *)NULL, (union str *)NULL, p2, TNULL0);
+                       p2 = block(ITOC, INT, (int *)NULL, (union str *)NULL, p2, TNULL);
                *cp0++ = p2;
                return;
        }
@@ -386,7 +386,7 @@ void build(op) int op; {
        }
 }
 
-void structident(p1, p2) register union tree0 *p1; register union tree0 *p2; {
+void structident(p1, p2) register union tree *p1; register union tree *p2; {
        register struct nmlist *np, *nporig;
        int vartypes = 0, namesame = 1;
 
@@ -396,7 +396,7 @@ void structident(p1, p2) register union tree0 *p1; register union tree0 *p2; {
                        p2->t.type = np->htype;
                        p2->t.strp = np->hstrp;
                        p2->t.subsp = np->hsubsp;
-                       p2->t.tr1 = (union tree0 *)np;
+                       p2->t.tr1 = (union tree *)np;
                        return;
                }
                np = np->nextnm;
@@ -421,7 +421,7 @@ void structident(p1, p2) register union tree0 *p1; register union tree0 *p2; {
 /*
  * Generate the appropriate conversion operator.
  */
-union tree0 *convert(p, t, cvn, len) union tree0 *p; int t; int cvn; int len; {
+union tree *convert(p, t, cvn, len) union tree *p; int t; int cvn; int len; {
        register int op;
 
        if (cvn==0)
@@ -432,7 +432,7 @@ union tree0 *convert(p, t, cvn, len) union tree0 *p; int t; int cvn; int len; {
                        error0("Illegal conversion");
                return(block(op, t, (int *)NULL, (union str *)NULL, p, cblock(len)));
        }
-       return(block(op, t, (int *)NULL, (union str *)NULL, p, TNULL0));
+       return(block(op, t, (int *)NULL, (union str *)NULL, p, TNULL));
 }
 
 /*
@@ -442,7 +442,7 @@ union tree0 *convert(p, t, cvn, len) union tree0 *p; int t; int cvn; int len; {
  * type at.
  * Used with structure references.
  */
-void setype(p, t, newp) register union tree0 *p; register int t; register union tree0 *newp; {
+void setype(p, t, newp) register union tree *p; register int t; register union tree *newp; {
        for (;; p = p->t.tr1) {
                p->t.subsp = newp->t.subsp;
                p->t.strp = newp->t.strp;
@@ -460,11 +460,11 @@ void setype(p, t, newp) register union tree0 *p; register int t; register union
  * A mention of a function name is turned into
  * a pointer to that function.
  */
-union tree0 *chkfun(p) register union tree0 *p; {
+union tree *chkfun(p) register union tree *p; {
        register int t;
 
        if (((t = p->t.type)&XTYPE)==FUNC && p->t.op!=ETYPE)
-               return(block(AMPER,incref0(t),p->t.subsp,p->t.strp,p,TNULL0));
+               return(block(AMPER,incref0(t),p->t.subsp,p->t.strp,p,TNULL));
        return(p);
 }
 
@@ -472,7 +472,7 @@ union tree0 *chkfun(p) register union tree0 *p; {
  * A mention of an array is turned into
  * a pointer to the base of the array.
  */
-union tree0 *disarray(p) register union tree0 *p; {
+union tree *disarray(p) register union tree *p; {
        register int t;
 
        if (p==NULL)
@@ -495,7 +495,7 @@ union tree0 *disarray(p) register union tree0 *p; {
  * okt might be nonexistent or 'long'
  * (e.g. for <<).
  */
-void chkw(p, okt) union tree0 *p; int okt; {
+void chkw(p, okt) union tree *p; int okt; {
        register int t = p->t.type;
 
        if (t == UNLONG)
@@ -579,15 +579,15 @@ void error0(s, va_alist) char *s; va_dcl
  * setting the operator, type, dimen/struct table ptrs,
  * and the operands.
  */
-union tree0 *block(op, t, subs, str, p1,p2) int op; int t; int *subs; union str *str; union tree0 *p1; union tree0 *p2; {
-       register union tree0 *p;
+union tree *block(op, t, subs, str, p1,p2) int op; int t; int *subs; union str *str; union tree *p1; union tree *p2; {
+       register union tree *p;
 
  /*fprintf(stderr, "block(%d, %d, {%d, %d}, {%d, %d})\n", op, t,
    (op == NAME) ? -2 : (p1 ? (int)(_INT)p1->t.op : -1),
    (op == NAME) ? -2 : (p1 ? (int)(_INT)p1->t.type : -1),
    (op == FSEL) ? -3 : (p2 ? (int)(_INT)p2->t.op : -1),
    (op == FSEL) ? -3 : (p2 ? (int)(_INT)p2->t.type : -1));*/
-       p = (union tree0 *)Tblock(sizeof(struct tnode0));
+       p = (union tree *)Tblock(sizeof(struct tnode));
        p->t.op = op;
        p->t.type = t;
        p->t.subsp = subs;
@@ -600,18 +600,18 @@ union tree0 *block(op, t, subs, str, p1,p2) int op; int t; int *subs; union str
        return(p);
 }
 
-union tree0 *nblock(ds) register struct nmlist *ds; {
-       return(block(NAME, ds->htype, ds->hsubsp, ds->hstrp, (union tree0 *)ds, TNULL0));
+union tree *nblock(ds) register struct nmlist *ds; {
+       return(block(NAME, ds->htype, ds->hsubsp, ds->hstrp, (union tree *)ds, TNULL));
 }
 
 /*
  * Generate a block for a constant
  */
-union tree0 *cblock(v) int v; {
-       register union tree0 *p;
+union tree *cblock(v) int v; {
+       register union tree *p;
 
  /*fprintf(stderr, "cblock(0%06o)\n", v & 0177777);*/
-       p = (union tree0 *)Tblock(sizeof(struct tconst0));
+       p = (union tree *)Tblock(sizeof(struct tconst));
        p->c.op = CON;
        p->c.type = INT;
        p->c.subsp = NULL;
@@ -623,11 +623,11 @@ union tree0 *cblock(v) int v; {
 /*
  * A block for a float constant
  */
-union tree0 *fblock(t, string) int t; char *string; {
-       register union tree0 *p;
+union tree *fblock(t, string) int t; char *string; {
+       register union tree *p;
 
  /*fprintf(stderr, "fblock(%d, \"%s\")\n", t, string);*/
-       p = (union tree0 *)Tblock(sizeof(struct ftconst0));
+       p = (union tree *)Tblock(sizeof(struct ftconst));
        p->f.op = FCON;
        p->f.type = t;
        p->f.subsp = NULL;
@@ -713,7 +713,7 @@ char *Dblock(n) int n; {
 /*
  * Check that a tree0 can be used as an lvalue.
  */
-void chklval(p) register union tree0 *p; {
+void chklval(p) register union tree *p; {
        if (p->t.op==FSEL)
                p = p->t.tr1;
        if (p->t.op!=NAME && p->t.op!=STAR)
@@ -726,7 +726,7 @@ void chklval(p) register union tree0 *p; {
  * but this is used to allow constant expressions
  * to be used in switches and array bounds.
  */
-int fold(op, p1, p2) int op; register union tree0 *p1; union tree0 *p2; {
+int fold(op, p1, p2) int op; register union tree *p1; union tree *p2; {
        register int v1, v2;
        int unsignf;
 
@@ -890,7 +890,7 @@ int fold(op, p1, p2) int op; register union tree0 *p1; union tree0 *p2; {
  * for example an array bound or a case value.
  */
 int conexp() {
-       register union tree0 *t;
+       register union tree *t;
  char *st = starttree();
        initflg++;
        if (t = tree0(/*1*/))
@@ -905,7 +905,7 @@ int conexp() {
 /*
  * Handle peculiar assignment ops that need a temporary.
  */
-void assignop(op, p1, p2) int op; register union tree0 *p1; register union tree0 *p2; {
+void assignop(op, p1, p2) int op; register union tree *p1; register union tree *p2; {
        register struct nmlist *np;
 
        op += PLUS - ASPLUS;
@@ -946,7 +946,7 @@ struct nmlist *gentemp(type) int type; {
        tp->hsubsp = NULL;
        tp->hstrp = NULL;
        tp->hblklev = blklev;
-       autolen -= rlength((union tree0 *)tp);
+       autolen -= rlength((union tree *)tp);
        tp->hoffset = autolen;
        if (autolen < maxauto)
                maxauto = autolen;
diff --git a/c02.c b/c02.c
index e9f3fa7..ef86619 100644 (file)
--- a/c02.c
+++ b/c02.c
@@ -57,7 +57,7 @@ void extdef() {
                                error0("Inappropriate parameters");
                } else if ((o=symbol())==COMMA || o==SEMI) {
                        peeksym = o;
-                       o = (length((union tree0 *)ds)+ALIGN) & ~ALIGN;
+                       o = (length((union tree *)ds)+ALIGN) & ~ALIGN;
                        if (sclass==STATIC) {
                                setinit(ds);
                                outcode("BSBBSBN", SYMDEF, "", BSS, NLABEL, ds->name, SSPACE, o);
@@ -132,7 +132,7 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; {
        struct nmlist np;
        register int nel, ninit;
        int width, isarray, o, brace, realtype;
-       union tree0 *s;
+       union tree *s;
 
        np = *anp;
        realtype = np.htype;
@@ -141,7 +141,7 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; {
                isarray++;
        else
                flex = 0;
-       width = length((union tree0 *)&np);
+       width = length((union tree *)&np);
        nel = 1;
        /*
         * If it's an array, find the number of elements.
@@ -156,7 +156,7 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; {
                np.hsubsp++;
                if (width==0 && flex==0)
                        error0("0-length row: %s", anp->name);
-               o = length((union tree0 *)&np);
+               o = length((union tree *)&np);
                nel = (unsigned)width/o;
                width = o;
        }
@@ -201,7 +201,7 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; {
                                anp->hoffset = s->c.value;
                        } else
                                rcexpr0(block(INIT,np.htype,(int *)NULL,
-                                 (union str *)NULL, (*--cp0)->t.tr2, TNULL0));
+                                 (union str *)NULL, (*--cp0)->t.tr2, TNULL));
                        endtree(st);
                }
                ninit++;
@@ -351,7 +351,7 @@ stmt:
 
                case IF: {
                        register int o2;
-                       register union tree0 *np;
+                       register union tree *np;
 
  char *st = starttree();
                        np = pexpr(/*1*/);
@@ -477,7 +477,7 @@ stmt:
                        goto stmt;
 
                case SWITCH: {
-                       register union tree0 *np;
+                       register union tree *np;
                        register char *st;
 
                        o1 = brklab;
@@ -485,7 +485,7 @@ stmt:
                        st = starttree();
                        np = pexpr(/*0*/);
                        chkw(np, -1);
-                       rcexpr0(block(RFORCE,0,(int *)NULL,(union str *)NULL,np,TNULL0));
+                       rcexpr0(block(RFORCE,0,(int *)NULL,(union str *)NULL,np,TNULL));
                        endtree(st);
                        pswitch0();
                        brklab = o1;
@@ -568,7 +568,7 @@ syntax:
  */
 int forstmt() {
        register int o;
-       register union tree0 *st;
+       register union tree *st;
        register int l;
        char *ss;
 
@@ -628,9 +628,9 @@ int forstmt() {
  * A parenthesized expression,
  * as after "if".
  */
-union tree0 *pexpr(/*eflag*/) /*int eflag;*/ {
+union tree *pexpr(/*eflag*/) /*int eflag;*/ {
        register int o;
-       register union tree0 *t;
+       register union tree *t;
 
        if ((o=symbol())!=LPARN)
                goto syntax;
@@ -685,7 +685,7 @@ void pswitch0() {
  * Structure resembling a block for a register variable.
  */
 struct nmlist  hreg    = { REG, 0, 0, NULL, NULL, 0 };
-struct tnode0  areg    = { NAME, 0, NULL, NULL, (union tree0 *)&hreg};
+struct tnode   areg    = { NAME, 0, NULL, NULL, 0/*degree*/, (union tree *)&hreg};
 void funchead() {
        register int pl;
        register struct nmlist *cs;
@@ -703,10 +703,10 @@ void funchead() {
                        cs->htype -= (ARRAY-PTR);       /* set ptr */
                        cs->hsubsp++;           /* pop dims */
                }
-               pl += rlength((union tree0 *)cs);
+               pl += rlength((union tree *)cs);
                if (cs->hclass==AREG && (hreg.hoffset=goodreg(cs))>=0) {
                        st = starttree();
-                       *cp0++ = (union tree0 *)&areg;
+                       *cp0++ = (union tree *)&areg;
                        *cp0++ = nblock(cs);
                        areg.type = cs->htype;
                        areg.strp = cs->hstrp;
diff --git a/c03.c b/c03.c
index bcc8a5b..cc173bb 100644 (file)
--- a/c03.c
+++ b/c03.c
@@ -255,7 +255,7 @@ int declare(askw, tptr, offset) int askw; struct nmlist *tptr; int offset; {
                isunion++;
                mosflg = FMOS;
                if ((peeksym=symbol()) == SEMI) {
-                       o = length((union tree0 *)tptr);
+                       o = length((union tree *)tptr);
                        if (o>offset)
                                offset = o;
                }
@@ -441,7 +441,7 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs
        }
        elsize = 0;
        if (skw==MOS) {
-               elsize = length((union tree0 *)dsym);
+               elsize = length((union tree *)dsym);
                if ((peeksym = symbol())==COLON) {
                        elsize = 0;
                        peeksym = -1;
@@ -484,7 +484,7 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs
                peeksym = a;
        if (skw==AUTO) {
        /*      if (STAUTO < 0) {       */
-                       autolen -= rlength((union tree0 *)dsym);
+                       autolen -= rlength((union tree *)dsym);
                        dsym->hoffset = autolen;
                        if (autolen < maxauto)
                                maxauto = autolen;
@@ -505,7 +505,7 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs
                                outcode("B", EVEN);
                } else
                        outcode("BBNBN", BSS, LABEL, isn0++, SSPACE,
-                         rlength((union tree0 *)dsym));
+                         rlength((union tree *)dsym));
                outcode("B", PROG);
                isinit = 0;
        } else if (skw==REG && isinit) {
diff --git a/c04.c b/c04.c
index a36b23a..40d4d89 100644 (file)
--- a/c04.c
+++ b/c04.c
@@ -36,7 +36,7 @@ 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.
  */
-void cbranch0(t, lbl, cond) union tree0 *t; int lbl; int cond; {
+void cbranch0(t, lbl, cond) union tree *t; int lbl; int cond; {
        treeout(t, 0);
        outcode("BNNN", CBRANCH, lbl, cond, line);
 }
@@ -44,7 +44,7 @@ void cbranch0(t, lbl, cond) union tree0 *t; int lbl; int cond; {
 /*
  * Write out a tree0.
  */
-void rcexpr0(tp) register union tree0 *tp; {
+void rcexpr0(tp) register union tree *tp; {
        /*
         * Special optimization
         */
@@ -61,7 +61,7 @@ void rcexpr0(tp) register union tree0 *tp; {
        outcode("BN", EXPR, line);
 }
 
-void treeout(tp, isstruct) register union tree0 *tp; int isstruct; {
+void treeout(tp, isstruct) register union tree *tp; int isstruct; {
        register struct nmlist *hp;
        register int nextisstruct;
 
@@ -159,7 +159,7 @@ void label0(l) int l; {
  * is some kind of pointer; return the size of the object
  * to which the pointer points.
  */
-int plength(p) register union tree0 *p; {
+int plength(p) register union tree *p; {
        register int t, l;
 
        if (p==0 || ((t=p->t.type)&~TYPE) == 0)         /* not a reference */
@@ -174,7 +174,7 @@ int plength(p) register union tree0 *p; {
  * return the number of bytes in the object
  * whose tree0 node is acs.
  */
-int length(cs) union tree0 *cs; {
+int length(cs) union tree *cs; {
        register int t, elsz;
        long n;
        int nd;
@@ -236,7 +236,7 @@ int length(cs) union tree0 *cs; {
 /*
  * The number of bytes in an object, rounded up to a word.
  */
-int rlength(cs) union tree0 *cs; {
+int rlength(cs) union tree *cs; {
        return((length(cs)+ALIGN) & ~ALIGN);
 }
 
@@ -306,14 +306,14 @@ void chconbrk(l) int l; {
  * The goto statement.
  */
 void dogoto() {
-       register union tree0 *np;
+       register union tree *np;
        register char *st;
 
        st = starttree();
        *cp0++ = tree0(/*0*/);
        build(STAR);
        chkw(np = *--cp0, -1);
-       rcexpr0(block(JUMP, 0, (int *)NULL, (union str *)NULL, np, TNULL0));
+       rcexpr0(block(JUMP, 0, (int *)NULL, (union str *)NULL, np, TNULL));
        endtree(st);
 }
 
@@ -326,7 +326,7 @@ void doret() {
                register char *st;
 
                st = starttree();
-               *cp0++ = (union tree0 *)&funcblk0;
+               *cp0++ = (union tree *)&funcblk0;
                *cp0++ = tree0(/*0*/);
                build(ASSIGN);
                cp0[-1] = cp0[-1]->t.tr2;
diff --git a/c1.h b/c1.h
index 9230d57..ac75952 100644 (file)
--- a/c1.h
+++ b/c1.h
@@ -8,97 +8,8 @@
 #include <setjmp.h>
 #include "ccom.h"
 
-#ifndef NULL
-#define        NULL    0
-#endif
-#define        TNULL1  (union tree1 *)NULL
 #define        UNS(x)  ((unsigned short)(x))
 
-/*
- *  Tree node for unary and binary
- */
-struct tnode1 {
-       int     op;
-       int     type;
-       int     degree;
-       union   tree1 *tr1;
-       union   tree1 *tr2;
-};
-
-/*
- * tree1 names for locals
- */
-struct tname {
-       int     op;
-       int     type;
-       char    class;
-       char    regno;
-       int     offset;
-       int     nloc;
-};
-
-/*
- * tree1 names for externals
- */
-struct xtname {
-       int     op;
-       int     type;
-       char    class;
-       char    regno;
-       int     offset;
-       char    *name;
-};
-
-/*
- * short constants
- */
-struct tconst1 {
-       int     op;
-       int     type;
-       _INT    value;
-};
-
-/*
- * long constants
- */
-struct lconst1 {
-       int     op;
-       int     type;
-       _LONG   lvalue;
-};
-
-/*
- * Floating constants
- */
-struct ftconst1 {
-       int     op;
-       int     type;
-       int     value;
-       _DOUBLE fvalue;
-};
-
-/*
- * Node used for field assignments
- */
-struct fasgn {
-       int     op;
-       int     type;
-       int     degree;
-       union   tree1 *tr1;
-       union   tree1 *tr2;
-       int     mask;
-};
-
-union  tree1 {
-       struct  tnode1 t;
-       struct tname n;
-       struct  xtname x;
-       struct  tconst1 c;
-       struct  lconst1 l;
-       struct  ftconst1 f;
-       struct  fasgn F;
-};
-
 struct optab {
        char    tabdeg1;
        char    tabtyp1;
@@ -194,7 +105,7 @@ extern struct tname sfuncr;
 extern char *funcbase;
 extern char *curbase;
 extern char *coremax;
-extern struct tconst1 czero, cone;
+extern struct tconst czero, cone;
 extern long totspace;
 extern int regpanic;           /* set when SU register alg. fails */
 extern int panicposs;          /* set when there might be need for regpanic */
@@ -202,21 +113,21 @@ extern jmp_buf jmpbuf;
 extern long ftell();
 /*extern char *sbrk();*/
 extern struct optab *match();
-extern union tree1 *optim();
-extern union tree1 *unoptim();
-extern union tree1 *pow2();
-extern union tree1 *tnode1();
-extern union tree1 *sdelay();
-extern union tree1 *ncopy();
-extern union tree1 *getblk();
-extern union tree1 *strfunc();
-extern union tree1 *isconstant();
-extern union tree1 *tconst1();
-extern union tree1 *hardlongs();
-extern union tree1 *lconst1();
-extern union tree1 *acommute();
-extern union tree1 *lvfield();
-extern union tree1 *paint();
+extern union tree *optim();
+extern union tree *unoptim();
+extern union tree *pow2();
+extern union tree *tnode1();
+extern union tree *sdelay();
+extern union tree *ncopy();
+extern union tree *getblk();
+extern union tree *strfunc();
+extern union tree *isconstant();
+extern union tree *tconst1();
+extern union tree *hardlongs();
+extern union tree *lconst1();
+extern union tree *acommute();
+extern union tree *lvfield();
+extern union tree *paint();
 extern long ftell();
 
 /*
@@ -229,8 +140,8 @@ extern int xlab1, xlab2, xop, xzero;
 struct acl {
        int nextl;
        int nextn;
-       union tree1 *nlist[LSTSIZ];
-       union tree1 *llist[LSTSIZ+1];
+       union tree *nlist[LSTSIZ];
+       union tree *llist[LSTSIZ+1];
 };
 #endif
 
@@ -244,41 +155,41 @@ struct acl {
 
 /* c10.c */
 int main __P((int argc, char *argv[]));
-struct optab *match __P((union tree1 *tree1, struct table *table, int nrleft, int nocvt));
-int rcexpr1 __P((union tree1 *atree, struct table *atable, int reg));
-int cexpr __P((register union tree1 *tree1, struct table *table, int areg));
-int reorder __P((union tree1 **treep, struct table *table, int reg));
-int sreorder __P((union tree1 **treep, struct table *table, int reg, int recurf));
-int delay __P((union tree1 **treep, struct table *table, int reg));
-union tree1 *sdelay __P((union tree1 **ap));
-union tree1 *paint __P((register union tree1 *tp, register int type));
-union tree1 *ncopy __P((register union tree1 *p));
-int chkleaf __P((register union tree1 *tree1, struct table *table, int reg));
-int comarg __P((register union tree1 *tree1, int *flagp));
-union tree1 *strfunc __P((register union tree1 *tp));
-void doinit __P((register int type, register union tree1 *tree1));
-void movreg __P((int r0, int r1, union tree1 *tree1));
+struct optab *match __P((union tree *tree1, 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 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));
+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));
 
 /* c11.c */
-int degree __P((register union tree1 *t));
-void pname __P((register union tree1 *p, int flag));
-void pbase __P((register union tree1 *p));
-int xdcalc __P((register union tree1 *p, int nrleft));
-int dcalc __P((register union tree1 *p, int nrleft));
-int notcompat __P((register union tree1 *p, int ast, int deg, int op));
+int degree __P((register union tree *t));
+void pname __P((register union tree *p, int flag));
+void pbase __P((register union tree *p));
+int xdcalc __P((register union tree *p, int nrleft));
+int dcalc __P((register union tree *p, int nrleft));
+int notcompat __P((register union tree *p, int ast, int deg, int op));
 int prins __P((int op, int c, struct instab *itable, int lbl));
-int collcon __P((register union tree1 *p));
-int isfloat __P((register union tree1 *t));
-int oddreg __P((register union tree1 *t, register int reg));
+int collcon __P((register union tree *p));
+int isfloat __P((register union tree *t));
+int oddreg __P((register union tree *t, register int reg));
 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 tree1 *tree1));
-union tree1 *pow2 __P((register union tree1 *tree1));
-void cbranch1 __P((union tree1 *atree, register int lbl, int cond, register int reg));
+int ispow2 __P((register union tree *tree1));
+union tree *pow2 __P((register union tree *tree1));
+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 tree1 *atree, int lbl, int cond, int reg));
+void longrel __P((union tree *atree, int lbl, int cond, int reg));
 int xlongrel __P((int f));
 void label1 __P((int l));
 void popstk __P((int a));
@@ -287,28 +198,28 @@ void error1 __P((char *s, ...));
 void psoct __P((int an));
 void getree __P((void));
 int geti __P((void));
-void strasg __P((union tree1 *atp));
+void strasg __P((union tree *atp));
 int decref1 __P((register int t));
 int incref1 __P((register int t));
 
 /* c12.c */
-union tree1 *optim __P((register union tree1 *tree1));
-union tree1 *unoptim __P((register union tree1 *tree1));
-union tree1 *lvfield __P((register union tree1 *t));
-union tree1 *acommute __P((register union tree1 *tree1));
-int sideeffects __P((register union tree1 *tp));
+union tree *optim __P((register union tree *tree1));
+union tree *unoptim __P((register union tree *tree1));
+union tree *lvfield __P((register union tree *t));
+union tree *acommute __P((register union tree *tree1));
+int sideeffects __P((register union tree *tp));
 void distrib __P((struct acl *list));
-void squash __P((union tree1 **p, union tree1 **maxp));
+void squash __P((union tree **p, union tree **maxp));
 void _const __P((int op, register _INT *vp, _INT v, int type));
-union tree1 *lconst1 __P((int op, register union tree1 *lp, register union tree1 *rp));
-void insert __P((int op, register union tree1 *tree1, register struct acl *list));
-union tree1 *tnode1 __P((int op, int type, union tree1 *tr1, union tree1 *tr2));
-union tree1 *tconst1 __P((int val, int type));
-union tree1 *getblk __P((int size));
+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 *tnode1 __P((int op, int type, union tree *tr1, union tree *tr2));
+union tree *tconst1 __P((int val, int type));
+union tree *getblk __P((int size));
 int islong __P((int t));
-union tree1 *isconstant __P((register union tree1 *t));
-union tree1 *hardlongs __P((register union tree1 *t));
-int uns __P((union tree1 *tp));
+union tree *isconstant __P((register union tree *t));
+union tree *hardlongs __P((register union tree *t));
+int uns __P((union tree *tp));
 
 #ifndef pdp11
 /* fp.c */
diff --git a/c10.c b/c10.c
index cdd52cd..06c39c0 100644 (file)
--- a/c10.c
+++ b/c10.c
@@ -27,8 +27,8 @@ char  notrel[] = {    NEQUAL, EQUAL, GREAT, GREATEQ, LESS,
                        LESSEQ, GREATP, GREATQP, LESSP, LESSEQP
 };
 
-struct tconst1 czero = { CON, INT, 0};
-struct tconst1 cone  = { CON, INT, 1};
+struct tconst czero = { CON, INT, 0/*subsp*/, 0/*strp*/, 0};
+struct tconst cone  = { CON, INT, 0/*subsp*/, 0/*strp*/, 1};
 
 struct tname sfuncr = { NAME, STRUCT, STATIC, 0, 0, 0 };
 
@@ -91,12 +91,12 @@ int main(argc, argv) int argc; char *argv[]; {
  * 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 tree1 *tree1; struct table *table; int nrleft; int nocvt; {
+struct optab *match(tree1, table, nrleft, nocvt) union tree *tree1; struct table *table; int nrleft; int nocvt; {
 #define        NOCVL   1
 #define        NOCVR   2
        int op, d1, d2, dope;
-       union tree1 *p2;
-       register union tree1 *p1;
+       union tree *p2;
+       register union tree *p1;
        register struct optab *opt;
 
        if (tree1==NULL)
@@ -179,10 +179,10 @@ struct optab *match(tree1, table, nrleft, nocvt) union tree1 *tree1; struct tabl
  * A number of special cases are recognized, and
  * there is an interaction with the optimizer routines.
  */
-int rcexpr1(atree, atable, reg) union tree1 *atree; struct table *atable; int reg; {
+int rcexpr1(atree, atable, reg) union tree *atree; struct table *atable; int reg; {
        register int r;
        int modf, nargs, recurf;
-       register union tree1 *tree1;
+       register union tree *tree1;
        register struct table *table;
 
  /*fprintf(stderr, "rcexpr1(0x%08x, 0x%08x, 0x%08x)\n", atree, atable, reg);*/
@@ -266,7 +266,7 @@ again:
        case ANDN:
                if (table==cctab) {
                        tree1->t.op = TAND;
-                       tree1->t.tr2 = optim(tnode1(COMPL, tree1->t.type, tree1->t.tr2, TNULL1));
+                       tree1->t.tr2 = optim(tnode1(COMPL, tree1->t.type, tree1->t.tr2, TNULL));
                }
                break;
 
@@ -337,11 +337,11 @@ again:
                if (tree1->t.tr2->t.op==ITOL)
                        tree1->t.tr2 = tree1->t.tr2->t.tr1;
                else
-                       tree1->t.tr2 = optim(tnode1(LTOI,INT,tree1->t.tr2,TNULL1));
+                       tree1->t.tr2 = optim(tnode1(LTOI,INT,tree1->t.tr2,TNULL));
                if (tree1->t.op==ASULSH)
                        {
                        tree1->t.op = UASLSHL;
-                       tree1->t.tr1 = tnode1(AMPER, LONG+PTR, tree1->t.tr1, TNULL1);
+                       tree1->t.tr1 = tnode1(AMPER, LONG+PTR, tree1->t.tr1, TNULL);
                        }
                else
                        tree1->t.op = ULLSHIFT;
@@ -353,7 +353,7 @@ again:
                        if (tree1->t.tr2->t.op==ITOL)
                                tree1->t.tr2 = tree1->t.tr2->t.tr1;
                        else
-                               tree1->t.tr2 = optim(tnode1(LTOI,INT,tree1->t.tr2,TNULL1));
+                               tree1->t.tr2 = optim(tnode1(LTOI,INT,tree1->t.tr2,TNULL));
                        if (tree1->t.op==ASLSH)
                                tree1->t.op = ASLSHL;
                        else
@@ -420,7 +420,7 @@ 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, TNULL1);
+               tree1->t.tr2 = tnode1(LOAD, UNSIGN, tree1->t.tr2, TNULL);
                return(rcexpr1(tree1, table, reg));
        }
        /*
@@ -454,11 +454,11 @@ again:
  * Most of the work is the macro-expansion of the
  * code table.
  */
-int cexpr(tree1, table, areg) register union tree1 *tree1; struct table *table; int areg; {
+int cexpr(tree1, table, areg) register union tree *tree1; struct table *table; int areg; {
        int c, r;
-       register union tree1 *p, *p1;
+       register union tree *p, *p1;
        struct table *ctable;
-       union tree1 *p2;
+       union tree *p2;
        char *string;
        int reg, reg1, rreg, flag, opd;
        struct optab *opt;
@@ -473,10 +473,10 @@ int cexpr(tree1, table, areg) register union tree1 *tree1; struct table *table;
         */
        if ((opd&RELAT||c==LOGAND||c==LOGOR||c==EXCLA) && table!=cctab) {
                cbranch1(tree1, c=isn1++, 1, reg);
-               rcexpr1((union tree1 *)&czero, table, reg);
+               rcexpr1((union tree *)&czero, table, reg);
                branch1(isn1, 0, 0);
                label1(c);
-               rcexpr1((union tree1 *)&cone, table, reg);
+               rcexpr1((union tree *)&cone, table, reg);
                label1(isn1++);
                return(reg);
        }
@@ -524,7 +524,7 @@ int cexpr(tree1, table, areg) register union tree1 *tree1; struct table *table;
        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, TNULL1);
+               tree1->t.tr2 = tnode1(LOAD, tree1->t.tr2->t.type, tree1->t.tr2, TNULL);
        /*
         * Another peculiarity of the PDP11 table manifested itself when
         * amplifying the move3: table.  The same case which optimizes
@@ -542,7 +542,7 @@ int cexpr(tree1, table, areg) register union tree1 *tree1; struct table *table;
        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, TNULL1);
+               tree1->t.tr2 = tnode1(LOAD, UNSIGN, tree1->t.tr2, TNULL);
        if (table==cregtab)
                table = regtab;
        /*
@@ -913,9 +913,9 @@ loop:
  * on the subtrees and then on the tree1 itself.
  * It returns non-zero if anything changed.
  */
-int reorder(treep, table, reg) union tree1 **treep; struct table *table; int reg; {
+int reorder(treep, table, reg) union tree **treep; struct table *table; int reg; {
        register int r, o;
-       register union tree1 *p;
+       register union tree *p;
 
        p = *treep;
        o = p->t.op;
@@ -944,8 +944,8 @@ int reorder(treep, table, reg) union tree1 **treep; struct table *table; int reg
  * Moreover, expressions like "reg = x+y" are best done as
  * "reg = x; reg += y" (so long as "reg" and "y" are not the same!).
  */
-int sreorder(treep, table, reg, recurf) union tree1 **treep; struct table *table; int reg; int recurf; {
-       register union tree1 *p, *p1;
+int sreorder(treep, table, reg, recurf) union tree **treep; struct table *table; int reg; int recurf; {
+       register union tree *p, *p1;
 
        p = *treep;
        if (opdope1[p->t.op]&LEAF)
@@ -953,7 +953,7 @@ int sreorder(treep, table, reg, recurf) union tree1 **treep; struct table *table
        if (p->t.op==PLUS && recurf)
                if (reorder(&p->t.tr2, table, reg))
                        *treep = p = optim(p);
-       if ((p1 = p->t.tr1)==TNULL1)
+       if ((p1 = p->t.tr1)==TNULL)
                return(0);
        if (p->t.op==STAR || p->t.op==PLUS) {
                if (recurf && reorder(&p->t.tr1, table, reg)) {
@@ -1038,8 +1038,8 @@ int sreorder(treep, table, reg, recurf) union tree1 **treep; struct table *table
  * Otherwise it uses sdelay to search for inc/dec
  * among the operands.
  */
-int delay(treep, table, reg) union tree1 **treep; struct table *table; int reg; {
-       register union tree1 *p, *p1;
+int delay(treep, table, reg) union tree **treep; struct table *table; int reg; {
+       register union tree *p, *p1;
        register int r;
 
        p = *treep;
@@ -1080,11 +1080,11 @@ int delay(treep, table, reg) union tree1 **treep; struct table *table; int reg;
        return(0);
 }
 
-union tree1 *sdelay(ap) union tree1 **ap; {
-       register union tree1 *p, *p1;
+union tree *sdelay(ap) union tree **ap; {
+       register union tree *p, *p1;
 
-       if ((p = *ap)==TNULL1)
-               return(TNULL1);
+       if ((p = *ap)==TNULL)
+               return(TNULL);
        if ((p->t.op==INCAFT||p->t.op==DECAFT) && p->t.tr1->t.op==NAME) {
                *ap = paint(ncopy(p->t.tr1), p->t.type);
                return(p);
@@ -1100,14 +1100,14 @@ union tree1 *sdelay(ap) union tree1 **ap; {
 /*
  * Propagate possible implicit type-changing operation
  */
-union tree1 *paint(tp, type) register union tree1 *tp; register int type; {
+union tree *paint(tp, type) register union tree *tp; register int type; {
 
        if (tp->t.type==type)
                return(tp);
        if (tp->t.type==CHAR && type==INT)
                return(tp);
        if (tp->t.type==CHAR || tp->t.type==UNCHAR)
-               return(optim(tnode1(LOAD, type, tp, TNULL1)));
+               return(optim(tnode1(LOAD, type, tp, TNULL)));
        tp->t.type = type;
        if (tp->t.op==AMPER && type&XTYPE)
                tp->t.tr1 = paint(tp->t.tr1, decref1(type));
@@ -1127,8 +1127,8 @@ union tree1 *paint(tp, type) register union tree1 *tp; register int type; {
  * be changed to some offset class, accidentally
  * modifying the reg--.
  */
-union tree1 *ncopy(p) register union tree1 *p; {
-       register union tree1 *q;
+union tree *ncopy(p) register union tree *p; {
+       register union tree *q;
 
        q = getblk(sizeof(struct xtname));
        q->n.op = p->n.op;
@@ -1147,8 +1147,8 @@ union tree1 *ncopy(p) register union tree1 *p; {
  * If the tree1 can be immediately loaded into a register,
  * produce code to do so and return success.
  */
-int chkleaf(tree1, table, reg) register union tree1 *tree1; struct table *table; int reg; {
-       struct tnode1 lbuf;
+int chkleaf(tree1, table, reg) register union tree *tree1; 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)
@@ -1160,7 +1160,7 @@ int chkleaf(tree1, table, reg) register union tree1 *tree1; struct table *table;
 #if 1 /* can't have garbage in lbuf.tr2, cexpr() will deref it if non-NULL */
        lbuf.tr2 = NULL;
 #endif
-       return(rcexpr1((union tree1 *)&lbuf, table, reg));
+       return(rcexpr1((union tree *)&lbuf, table, reg));
 }
 
 /*
@@ -1170,7 +1170,7 @@ int chkleaf(tree1, table, reg) register union tree1 *tree1; struct table *table;
  * Return the number of bytes pushed,
  * for future popping.
  */
-int comarg(tree1, flagp) register union tree1 *tree1; int *flagp; {
+int comarg(tree1, flagp) register union tree *tree1; int *flagp; {
        register int retval;
        int i;
        int size;
@@ -1191,7 +1191,7 @@ int comarg(tree1, flagp) register union tree1 *tree1; int *flagp; {
                        error1("Unimplemented structure assignment");
                        return(0);
                }
-               tree1 = tnode1(AMPER, STRUCT+PTR, tree1, TNULL1);
+               tree1 = tnode1(AMPER, STRUCT+PTR, tree1, TNULL);
                tree1 = tnode1(PLUS, STRUCT+PTR, tree1, tconst1(size, INT));
                tree1 = optim(tree1);
                retval = rcexpr1(tree1, regtab, 0);
@@ -1221,17 +1221,17 @@ normal:
        return(retval);
 }
 
-union tree1 *strfunc(tp) register union tree1 *tp; {
+union tree *strfunc(tp) register union tree *tp; {
        if (tp->t.op != CALL)
                return(tp);
        paint(tp, STRUCT+PTR);
-       return(tnode1(STAR, STRUCT, tp, TNULL1));
+       return(tnode1(STAR, STRUCT, tp, TNULL));
 }
 
 /*
  * Compile an initializing expression
  */
-void doinit(type, tree1) register int type; register union tree1 *tree1; {
+void doinit(type, tree1) register int type; register union tree *tree1; {
        _FLOAT sfval;
        _DOUBLE fval;
        _LONG lval;
@@ -1363,7 +1363,7 @@ illinit:
        error1("Illegal initialization");
 }
 
-void movreg(r0, r1, tree1) int r0; int r1; union tree1 *tree1; {
+void movreg(r0, r1, tree1) int r0; int r1; union tree *tree1; {
        register char *s;
        char c;
 
diff --git a/c11.c b/c11.c
index e25474d..f6c6f61 100644 (file)
--- a/c11.c
+++ b/c11.c
@@ -18,8 +18,8 @@
 /*static void outname __P((char *s));*/
 static void outname __P((char *buf, char *str));
 
-int degree(t) register union tree1 *t; {
-       register union tree1 *t1;
+int degree(t) register union tree *t; {
+       register union tree *t1;
 
        if (t==NULL || t->t.op==0)
                return(0);
@@ -41,7 +41,7 @@ int degree(t) register union tree1 *t; {
        return(t->t.degree);
 }
 
-void pname(p, flag) register union tree1 *p; int flag; {
+void pname(p, flag) register union tree *p; int flag; {
        register int i;
 
 loop:
@@ -120,7 +120,7 @@ loop:
        error1("compiler error1: bad pname");
 }
 
-void pbase(p) register union tree1 *p; {
+void pbase(p) register union tree *p; {
 
        if (p->n.class==SOFFS || p->n.class==STATIC)
                fprintf(temp_fp[temp_fi], /*printf(*/"L%d", p->n.nloc);
@@ -128,7 +128,7 @@ void pbase(p) register union tree1 *p; {
                fprintf(temp_fp[temp_fi], /*printf(*/"%s", p->x.name);
 }
 
-int xdcalc(p, nrleft) register union tree1 *p; int nrleft; {
+int xdcalc(p, nrleft) register union tree *p; int nrleft; {
        register int d;
 
        if (p==NULL)
@@ -143,8 +143,8 @@ int xdcalc(p, nrleft) register union tree1 *p; int nrleft; {
        return(d);
 }
 
-int dcalc(p, nrleft) register union tree1 *p; int nrleft; {
-       register union tree1 *p1;
+int dcalc(p, nrleft) register union tree *p; int nrleft; {
+       register union tree *p1;
 
        if (p==NULL)
                return(0);
@@ -182,7 +182,7 @@ int dcalc(p, nrleft) register union tree1 *p; int nrleft; {
        return(p->t.degree <= nrleft? 20: 24);
 }
 
-int notcompat(p, ast, deg, op) register union tree1 *p; int ast; int deg; int op; {
+int notcompat(p, ast, deg, op) register union tree *p; int ast; int deg; int op; {
        unsigned register at, st;
 
        at = p->t.type;
@@ -236,7 +236,7 @@ int prins(op, c, itable, lbl) int op; int c; struct instab *itable; int lbl; {
        return(skip);
 }
 
-int collcon(p) register union tree1 *p; {
+int collcon(p) register union tree *p; {
        register int op;
 
        if (p==NULL)
@@ -254,7 +254,7 @@ int collcon(p) register union tree1 *p; {
        return(0);
 }
 
-int isfloat(t) register union tree1 *t; {
+int isfloat(t) register union tree *t; {
 
        if ((opdope1[t->t.op]&RELAT)!=0)
                t = t->t.tr1;
@@ -265,7 +265,7 @@ int isfloat(t) register union tree1 *t; {
        return(0);
 }
 
-int oddreg(t, reg) register union tree1 *t; register int reg; {
+int oddreg(t, reg) register union tree *t; register int reg; {
 
        if (!isfloat(t)) {
                if (opdope1[t->t.op]&RELAT) {
@@ -470,7 +470,7 @@ int sort(afp, alp) struct swtab *afp; struct swtab *alp; {
        return(0);
 }
 
-int ispow2(tree1) register union tree1 *tree1; {
+int ispow2(tree1) register union tree *tree1; {
        register int d;
 
        if (!isfloat(tree1) && tree1->t.tr2->t.op==CON) {
@@ -481,7 +481,7 @@ int ispow2(tree1) register union tree1 *tree1; {
        return(0);
 }
 
-union tree1 *pow2(tree1) register union tree1 *tree1; {
+union tree *pow2(tree1) register union tree *tree1; {
        register int d, i;
 
        if (d = ispow2(tree1)) {
@@ -500,14 +500,14 @@ union tree1 *pow2(tree1) register union tree1 *tree1; {
                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, TNULL1);
+                               tree1->t.tr1 = tnode1(LTOI, INT, tree1->t.tr1, TNULL);
                                return(optim(tree1));
                        }
                        tree1->t.op = LLSHIFT;
                        tree1->t.tr2->c.value = -i;
                        i = tree1->t.type;
                        tree1->t.type = LONG;
-                       tree1 = tnode1(LTOI, i, tree1, TNULL1);
+                       tree1 = tnode1(LTOI, i, tree1, TNULL);
                        break;
 
                case DIVIDE:
@@ -538,9 +538,9 @@ union tree1 *pow2(tree1) register union tree1 *tree1; {
        return(tree1);
 }
 
-void cbranch1(atree, lbl, cond, reg) union tree1 *atree; register int lbl; int cond; register int reg; {
+void cbranch1(atree, lbl, cond, reg) union tree *atree; register int lbl; int cond; register int reg; {
        int l1, op;
-       register union tree1 *tree1;
+       register union tree *tree1;
 
 again:
        if ((tree1=atree)==NULL)
@@ -641,10 +641,10 @@ void branch1(lbl, aop, c) int lbl; int aop; int c; {
                fprintf(temp_fp[temp_fi], /*printf(*/"\tL%d\n", lbl);
 }
 
-void longrel(atree, lbl, cond, reg) union tree1 *atree; int lbl; int cond; int reg; {
+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 tree1 *tree1;
+       register union tree *tree1;
 
        if (reg&01)
                reg++;
@@ -669,7 +669,7 @@ void longrel(atree, lbl, cond, reg) union tree1 *atree; int lbl; int cond; int r
                && 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, TNULL1));
+               tree1->t.tr2 = optim(tnode1(COMPL, LONG, tree1->t.tr2, TNULL));
        }
        if (cexpr(tree1, cctab, reg) < 0) {
                reg = rcexpr1(tree1, regtab, reg);
@@ -812,9 +812,9 @@ void outcode(fmt, va_alist) char *fmt; va_dcl
 #endif
 {
  va_list argp;
- /*    union tree1 *expstack[STKS], **sp;*/
- static union tree1 *expstack[STKS], **sp = expstack;
-       register union tree1 *tp;
+ /*    union tree *expstack[STKS], **sp;*/
+ static union tree *expstack[STKS], **sp = expstack;
+       register union tree *tp;
        register int t, op;
        char s[80];             /* big for asm() stuff & long variable names */
        struct swtab *swp;
@@ -978,7 +978,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl
                        rcexpr1(tp, efftab, 0);
                else {
                        if (tp->t.type==LONG || tp->t.type==UNLONG) {
-                               rcexpr1(tnode1(RFORCE, tp->t.type, tp, TNULL1), efftab, 0);
+                               rcexpr1(tnode1(RFORCE, tp->t.type, tp, TNULL), efftab, 0);
                                fprintf(temp_fp[temp_fi], /*printf(*/"ashc      $0,r0\n");
                        } else {
                                rcexpr1(tp, cctab, 0);
@@ -1021,10 +1021,10 @@ 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), TNULL1);
+                       *sp++ = tnode1(ITOL, LONG, tconst1(op, INT), TNULL);
                        break;
                }
-               tp = getblk(sizeof(struct lconst1));
+               tp = getblk(sizeof(struct lconst));
                tp->t.op = LCON;
                tp->t.type = LONG;
                tp->l.lvalue = ((_LONG)t<<16) + UNS(op); /* nonportable */
@@ -1034,7 +1034,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl
        case FCON:
                t = va_arg(argp, int) /*geti()*/;
                outname(s/*)*/, va_arg(argp, char *));
-               tp = getblk(sizeof(struct ftconst1));
+               tp = getblk(sizeof(struct ftconst));
                tp->t.op = FCON;
                tp->t.type = t;
                tp->f.value = isn1++;
@@ -1047,7 +1047,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl
                break;
 
        case FSEL:
-               tp = tnode1(FSEL, va_arg(argp, int) /*geti()*/, *--sp, TNULL1);
+               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));
                if (tp->t.tr2->t.tr1->c.value==16)
@@ -1066,7 +1066,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl
                break;
 
        case NULLOP:
-               *sp++ = tnode1(0, 0, TNULL1, TNULL1);
+               *sp++ = tnode1(0, 0, TNULL, TNULL);
                break;
 
        case LABEL:
@@ -1104,7 +1104,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl
                        *sp++ = tnode1(op, va_arg(argp, int) /*geti()*/, *--sp, tp);
 #endif
                } else
-                       sp[-1] = tnode1(op, va_arg(argp, int) /*geti()*/, sp[-1], TNULL1);
+                       sp[-1] = tnode1(op, va_arg(argp, int) /*geti()*/, sp[-1], TNULL);
                break;
        }
        }
@@ -1146,8 +1146,8 @@ static void outname(s) register char *s; {
 }
 #endif
 
-void strasg(atp) union tree1 *atp; {
-       register union tree1 *tp;
+void strasg(atp) union tree *atp; {
+       register union tree *tp;
        register int nwords, i;
 
        nwords = atp->F.mask/sizeof(_INT);
@@ -1163,7 +1163,7 @@ void strasg(atp) union tree1 *atp; {
                                fprintf(temp_fp[temp_fi], /*printf(*/".bss\nL%d:.=.+%o\n.text\n", sfuncr.nloc,
                                        UNS(nwords*sizeof(_INT)));
                        }
-                       atp->t.tr1 = tnode1(ASSIGN, STRUCT, (union tree1 *)&sfuncr, tp->t.tr1);
+                       atp->t.tr1 = tnode1(ASSIGN, STRUCT, (union tree *)&sfuncr, tp->t.tr1);
                        strasg(atp);
                        fprintf(temp_fp[temp_fi], /*printf(*/"mov       $L%d,r0\n", sfuncr.nloc);
                        return;
@@ -1186,8 +1186,8 @@ void strasg(atp) union tree1 *atp; {
                        error1("unimplemented structure assignment");
                        return;
                }
-               tp->t.tr1 = tnode1(AMPER, STRUCT+PTR, tp->t.tr1, TNULL1);
-               tp->t.tr2 = tnode1(AMPER, STRUCT+PTR, tp->t.tr2, TNULL1);
+               tp->t.tr1 = tnode1(AMPER, STRUCT+PTR, tp->t.tr1, TNULL);
+               tp->t.tr2 = tnode1(AMPER, STRUCT+PTR, tp->t.tr2, TNULL);
                tp->t.op = STRSET;
                tp->t.type = STRUCT+PTR;
                tp = optim(tp);
diff --git a/c12.c b/c12.c
index 520eb8b..c6761c5 100644 (file)
--- a/c12.c
+++ b/c12.c
 #define        min(a,b) (((a)<(b))?(a):(b))
 #define        max(a,b) (((a)>(b))?(a):(b))
 
-union tree1 *optim(tree1) register union tree1 *tree1; {
+union tree *optim(tree1) register union tree *tree1; {
        register int op, dope;
        int d1, d2;
-       union tree1 *t;
+       union tree *t;
 #ifdef pdp11
        union { double dv; _INT iv[4];} fp11;
 #endif
@@ -64,7 +64,7 @@ union tree1 *optim(tree1) register union tree1 *tree1; {
         */
        case ASAND:
                tree1->t.op = ASANDN;
-               tree1->t.tr2 = tnode1(COMPL, tree1->t.tr2->t.type, tree1->t.tr2, TNULL1);
+               tree1->t.tr2 = tnode1(COMPL, tree1->t.tr2->t.type, tree1->t.tr2, TNULL);
                break;
 
        /*
@@ -73,7 +73,7 @@ union tree1 *optim(tree1) register union tree1 *tree1; {
         */
        case LTOP:
                tree1->t.op = ITOP;
-               tree1->t.tr1 = unoptim(tnode1(LTOI,INT,tree1->t.tr1, TNULL1));
+               tree1->t.tr1 = unoptim(tnode1(LTOI,INT,tree1->t.tr1, TNULL));
        case ITOP:
                tree1->t.op = TIMES;
                break;
@@ -117,7 +117,7 @@ union tree1 *optim(tree1) register union tree1 *tree1; {
                        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, TNULL1);
+                       tree1->t.tr1 = tnode1(LTOI, UNSIGN, tree1->t.tr1, TNULL);
                        return(optim(t));
                }
                /*
@@ -131,7 +131,7 @@ union tree1 *optim(tree1) register union tree1 *tree1; {
                }
                tree1->t.op = ANDN;
                op = ANDN;
-               tree1->t.tr2 = tnode1(COMPL, tree1->t.tr2->t.type, tree1->t.tr2, TNULL1);
+               tree1->t.tr2 = tnode1(COMPL, tree1->t.tr2->t.type, tree1->t.tr2, TNULL);
        }
     again:
        tree1->t.tr1 = optim(tree1->t.tr1);
@@ -212,7 +212,7 @@ union tree1 *optim(tree1) register union tree1 *tree1; {
        case ASTIMES:
                if (tree1->t.tr2->t.op==CON && tree1->t.tr2->c.value==1) {
                        if (op==PTOI)
-                               return(optim(tnode1(LTOI,INT,paint(tree1->t.tr1,LONG), TNULL1)));
+                               return(optim(tnode1(LTOI,INT,paint(tree1->t.tr1,LONG), TNULL)));
                        return(paint(tree1->t.tr1, tree1->t.type));
                }
        case MOD:
@@ -268,7 +268,7 @@ union tree1 *optim(tree1) register union tree1 *tree1; {
                        goto constant;
                op += (LSHIFT-RSHIFT);
                tree1->t.op = op;
-               tree1->t.tr2 = tnode1(NEG, tree1->t.tr2->t.type, tree1->t.tr2, TNULL1);
+               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;
@@ -294,9 +294,9 @@ union tree1 *optim(tree1) register union tree1 *tree1; {
                                tree1 = tree1->t.tr1;
                                switch(op) {
                                case GREATEQ:
-                                       return((union tree1 *)&cone);
+                                       return((union tree *)&cone);
                                case LESS:
-                                       return((union tree1 *)&czero);
+                                       return((union tree *)&czero);
                                case LESSEQ:
                                case EQUAL:
                                        tree1->t.op = notrel[tree1->t.op-EQUAL];
@@ -310,8 +310,8 @@ union tree1 *optim(tree1) register union tree1 *tree1; {
        return(tree1);
 }
 
-union tree1 *unoptim(tree1) register union tree1 *tree1; {
-       register union tree1 *subtre, *p;
+union tree *unoptim(tree1) register union tree *tree1; {
+       register union tree *subtre, *p;
 
        if (tree1==NULL)
                return(NULL);
@@ -332,7 +332,7 @@ union tree1 *unoptim(tree1) register union tree1 *tree1; {
 
        case ITOL:
                if (subtre->t.op==CON && subtre->t.type==INT && subtre->c.value<0) {
-                       subtre = getblk(sizeof(struct lconst1));
+                       subtre = getblk(sizeof(struct lconst));
                        subtre->t.op = LCON;
                        subtre->t.type = LONG;
                        subtre->l.lvalue = tree1->t.tr1->c.value;
@@ -344,13 +344,13 @@ union tree1 *unoptim(tree1) register union tree1 *tree1; {
                if (uns(tree1)) {
                        tree1->t.op = FTOL;
                        tree1->t.type = LONG;
-                       tree1 = tnode1(LTOI, UNSIGN, tree1, TNULL1);
+                       tree1 = tnode1(LTOI, UNSIGN, tree1, TNULL);
                }
                break;
 
        case LTOF:
                if (subtre->t.op==LCON) {
-                       tree1 = getblk(sizeof(struct ftconst1));
+                       tree1 = getblk(sizeof(struct ftconst));
                        tree1->t.op = FCON;
                        tree1->t.type = DOUBLE;
                        tree1->f/*c*/.value = isn1++;
@@ -367,7 +367,7 @@ union tree1 *unoptim(tree1) register union tree1 *tree1; {
 
        case ITOF:
                if (subtre->t.op==CON) {
-                       tree1 = getblk(sizeof(struct ftconst1));
+                       tree1 = getblk(sizeof(struct ftconst));
                        tree1->t.op = FCON;
                        tree1->t.type = DOUBLE;
                        tree1->f.value = isn1++;
@@ -386,7 +386,7 @@ union tree1 *unoptim(tree1) register union tree1 *tree1; {
                        return(optim(tree1));
                }
                if (uns(subtre)) {
-                       tree1->t.tr1 = tnode1(ITOL, LONG, subtre, TNULL1);
+                       tree1->t.tr1 = tnode1(ITOL, LONG, subtre, TNULL);
                        tree1->t.op = LTOF;
                        return(optim(tree1));
                }
@@ -437,10 +437,10 @@ union tree1 *unoptim(tree1) register union tree1 *tree1; {
                case ANDN:
                case OR:
                case EXOR:
-                       subtre->t.tr2 = tnode1(LTOI, tree1->t.type, subtre->t.tr2, TNULL1);
+                       subtre->t.tr2 = tnode1(LTOI, tree1->t.type, subtre->t.tr2, TNULL);
                case NEG:
                case COMPL:
-                       subtre->t.tr1 = tnode1(LTOI, tree1->t.type, subtre->t.tr1, TNULL1);
+                       subtre->t.tr1 = tnode1(LTOI, tree1->t.type, subtre->t.tr1, TNULL);
                        subtre->t.type = tree1->t.type;
                        return(optim(subtre));
                }
@@ -553,7 +553,7 @@ union tree1 *unoptim(tree1) register union tree1 *tree1; {
                }
                if (subtre->t.op==ITOL) {
                        if (subtre->t.tr1->t.op==CON) {
-                               tree1 = getblk(sizeof(struct lconst1));
+                               tree1 = getblk(sizeof(struct lconst));
                                tree1->t.op = LCON;
                                tree1->t.type = LONG;
                                if (uns(subtre->t.tr1))
@@ -587,7 +587,7 @@ union tree1 *unoptim(tree1) register union tree1 *tree1; {
                        return(subtre);
                }
                if (subtre->t.op==ITOL && subtre->t.tr1->t.op==CON) {
-                       tree1 = getblk(sizeof(struct lconst1));
+                       tree1 = getblk(sizeof(struct lconst));
                        tree1->t.op = LCON;
                        tree1->t.type = LONG;
                        if (uns(subtre->t.tr1))
@@ -633,8 +633,8 @@ union tree1 *unoptim(tree1) register union tree1 *tree1; {
  * Pure assignment is handled specially.
  */
 
-union tree1 *lvfield(t) register union tree1 *t; {
-       register union tree1 *t1, *t2;
+union tree *lvfield(t) register union tree *t; {
+       register union tree *t1, *t2;
 
        switch (t->t.op) {
 
@@ -677,16 +677,16 @@ union tree1 *lvfield(t) register union tree1 *t; {
 struct acl {
        int nextl;
        int nextn;
-       union tree1 *nlist[LSTSIZ];
-       union tree1 *llist[LSTSIZ+1];
+       union tree *nlist[LSTSIZ];
+       union tree *llist[LSTSIZ+1];
 };
 #endif
 
-union tree1 *acommute(tree1) register union tree1 *tree1; {
+union tree *acommute(tree1) register union tree *tree1; {
        struct acl acl;
        int d, i, op, flt, d1, type;
-       register union tree1 *t1, **t2;
-       union tree1 *t;
+       register union tree *t1, **t2;
+       union tree *t;
 
        acl.nextl = 0;
        acl.nextn = 0;
@@ -721,7 +721,7 @@ union tree1 *acommute(tree1) register union tree1 *tree1; {
                }
                if (acl.nextl <= 0) {
                        if ((*t2)->t.type==CHAR || (*t2)->t.type==UNCHAR)
-                               *t2 = tnode1(LOAD, tree1->t.type, *t2, TNULL1);
+                               *t2 = tnode1(LOAD, tree1->t.type, *t2, TNULL);
                        (*t2)->t.type = tree1->t.type;
                        return(*t2);
                }
@@ -767,7 +767,7 @@ union tree1 *acommute(tree1) register union tree1 *tree1; {
                 * rt. op of ^ must be in a register.
                 */
                if (op==EXOR && dcalc(t, 0)<=12) {
-                       t1->t.tr2 = t = optim(tnode1(LOAD, t->t.type, t, TNULL1));
+                       t1->t.tr2 = t = optim(tnode1(LOAD, t->t.type, t, TNULL));
                        d1 = t->t.degree;
                }
                t1->t.degree = d = d==d1? d+islong(t1->t.type): max(d, d1);
@@ -792,7 +792,7 @@ union tree1 *acommute(tree1) register union tree1 *tree1; {
        return(tree1);
 }
 
-int sideeffects(tp) register union tree1 *tp; {
+int sideeffects(tp) register union tree *tp; {
        register int dope;
 
        if (tp==NULL)
@@ -826,11 +826,11 @@ void distrib(list) struct acl *list; {
  * fewest divisors. Reduce this pair to c1*(y+c2*x)
  * and iterate until no reductions occur.
  */
-       register union tree1 **p1, **p2;
-       union tree1 *t;
+       register union tree **p1, **p2;
+       union tree *t;
        int ndmaj, ndmin;
-       union tree1 **dividend, **divisor;
-       union tree1 **maxnod, **mindiv;
+       union tree **dividend, **divisor;
+       union tree **maxnod, **mindiv;
 
     loop:
        maxnod = &list->llist[list->nextl];
@@ -889,8 +889,8 @@ void distrib(list) struct acl *list; {
        goto loop;
 }
 
-void squash(p, maxp) union tree1 **p; union tree1 **maxp; {
-       register union tree1 **np;
+void squash(p, maxp) union tree **p; union tree **maxp; {
+       register union tree **np;
 
        for (np = p; np < maxp; np++)
                *np = *(np+1);
@@ -993,7 +993,7 @@ void _const(op, vp, v, type) int op; register _INT *vp; register _INT v; int typ
        error1("C error1: const");
 }
 
-union tree1 *lconst1(op, lp, rp) int op; register union tree1 *lp; register union tree1 *rp; {
+union tree *lconst1(op, lp, rp) int op; register union tree *lp; register union tree *rp; {
        _UNSIGNED_LONG l, r;
 
        if (lp->t.op==LCON)
@@ -1076,17 +1076,17 @@ union tree1 *lconst1(op, lp, rp) int op; register union tree1 *lp; register unio
                lp->l.lvalue = l;
                return(lp);
        }
-       lp = getblk(sizeof(struct lconst1));
+       lp = getblk(sizeof(struct lconst));
        lp->t.op = LCON;
        lp->t.type = LONG;
        lp->l.lvalue = l;
        return(lp);
 }
 
-void insert(op, tree1, list) int op; register union tree1 *tree1; register struct acl *list; {
+void insert(op, tree1, list) int op; register union tree *tree1; register struct acl *list; {
        register int d;
        int d1, i;
-       union tree1 *t;
+       union tree *t;
 
 ins:
        if (tree1->t.op != op)
@@ -1127,10 +1127,10 @@ ins:
        list->llist[list->nextl++] = tree1;
 }
 
-union tree1 *tnode1(op, type, tr1, tr2) int op; int type; union tree1 *tr1; union tree1 *tr2; {
-       register union tree1 *p;
+union tree *tnode1(op, type, tr1, tr2) int op; int type; union tree *tr1; union tree *tr2; {
+       register union tree *p;
 
-       p = getblk(sizeof(struct tnode1));
+       p = getblk(sizeof(struct tnode));
        p->t.op = op;
        p->t.type = type;
        p->t.degree = 0;
@@ -1139,25 +1139,25 @@ union tree1 *tnode1(op, type, tr1, tr2) int op; int type; union tree1 *tr1; unio
        return(p);
 }
 
-union tree1 *tconst1(val, type) int val; int type; {
-       register union tree1 *p;
+union tree *tconst1(val, type) int val; int type; {
+       register union tree *p;
 
-       p = getblk(sizeof(struct tconst1));
+       p = getblk(sizeof(struct tconst));
        p->t.op = CON;
        p->t.type = type;
        p->c.value = val;
        return(p);
 }
 
-union tree1 *getblk(size) int size; {
+union tree *getblk(size) int size; {
 #if 1
- return (union tree1 *)Tblock(size);
+ return (union tree *)Tblock(size);
 #else
-       register union tree1 *p;
+       register union tree *p;
 
        if (size&01)
                size++;
-       p = (union tree1 *)curbase;
+       p = (union tree *)curbase;
        if ((curbase += size) >= coremax) {
 #ifdef pdp11
                if (sbrk(1024) == (char *)-1) {
@@ -1179,7 +1179,7 @@ int islong(t) int t; {
        return(1);
 }
 
-union tree1 *isconstant(t) register union tree1 *t; {
+union tree *isconstant(t) register union tree *t; {
        if (t->t.op==CON || t->t.op==SFCON)
                return(t);
        if (t->t.op==ITOL && t->t.tr1->t.op==CON)
@@ -1187,7 +1187,7 @@ union tree1 *isconstant(t) register union tree1 *t; {
        return(NULL);
 }
 
-union tree1 *hardlongs(t) register union tree1 *t; {
+union tree *hardlongs(t) register union tree *t; {
        switch(t->t.op) {
 
        case TIMES:
@@ -1206,7 +1206,7 @@ union tree1 *hardlongs(t) register union tree1 *t; {
                        t->t.op += ULASTIMES-ASTIMES;
                else
                        t->t.op += LASTIMES-ASTIMES;
-               t->t.tr1 = tnode1(AMPER, LONG+PTR, t->t.tr1, TNULL1);
+               t->t.tr1 = tnode1(AMPER, LONG+PTR, t->t.tr1, TNULL);
                break;
 
        default:
@@ -1218,7 +1218,7 @@ union tree1 *hardlongs(t) register union tree1 *t; {
 /*
  * Is tree1 of unsigned type?
  */
-int uns(tp) union tree1 *tp; {
+int uns(tp) union tree *tp; {
        register int t;
 
        t = tp->t.type;
diff --git a/ccom.h b/ccom.h
index 617b00d..f6ef2b5 100644 (file)
--- a/ccom.h
+++ b/ccom.h
@@ -20,6 +20,107 @@ typedef struct { uint32_t h; } _FLOAT;
 typedef struct { uint32_t l; uint32_t h; } _DOUBLE;
 #endif
 
+#ifndef NULL
+#define        NULL    0
+#endif
+#define        TNULL   (union tree *)NULL
+
+/*
+ *  Tree node for unary and binary
+ */
+struct tnode {
+       int     op;
+       int     type;
+       int     *subsp;         /* subscript list for arrays; pass 0 only */
+       union   str *strp;      /* structure descr for structs; pass 0 only */
+       int     degree;         /* pass 1 only */
+       union   tree *tr1;
+       union   tree *tr2;
+};
+
+/*
+ * tree1 names for locals
+ */
+struct tname {
+       int     op;
+       int     type;
+       char    class;
+       char    regno;
+       int     offset;
+       int     nloc;
+};
+
+/*
+ * tree1 names for externals
+ */
+struct xtname {
+       int     op;
+       int     type;
+       char    class;
+       char    regno;
+       int     offset;
+       char    *name;
+};
+
+/*
+ * short constants
+ */
+struct tconst {
+       int     op;
+       int     type;
+       int     *subsp;         /* subscript list for arrays; pass 0 only */
+       union   str *strp;      /* structure descr for structs; pass 0 only */
+       _INT    value;
+};
+
+/*
+ * long constants
+ */
+struct lconst {
+       int     op;
+       int     type;
+       int     *subsp;         /* subscript list for arrays; pass 0 only */
+       union   str *strp;      /* structure descr for structs; pass 0 only */
+       _LONG   lvalue;
+};
+
+/*
+ * Floating constants
+ */
+struct ftconst {
+       int     op;
+       int     type;
+       int     *subsp;         /* subscript list for arrays; pass 0 only */
+       union   str *strp;      /* structure descr for structs; pass 0 only */
+       char    *cstr;          /* pass 0 only */
+       int     value;          /* pass 1 only */
+       _DOUBLE fvalue;         /* pass 1 only */
+};
+
+/*
+ * Node used for field assignments
+ */
+struct fasgn {
+       int     op;
+       int     type;
+       int     *subsp;         /* subscript list for arrays; pass 0 only */
+       union   str *strp;      /* structure descr for structs; pass 0 only */
+       int     degree;         /* pass 1 only */
+       union   tree *tr1;
+       union   tree *tr2;
+       int     mask;
+};
+
+union  tree {
+       struct  tnode t;
+       struct  tname n;                /* pass 1 only */
+       struct  xtname x;               /* pass 1 only */
+       struct  tconst c;
+       struct  lconst l;
+       struct  ftconst f;
+       struct  fasgn F;                /* pass 1 only */
+};
+
 /*
  * Table for recording switches.
  */
diff --git a/unify01.sed b/unify01.sed
new file mode 100644 (file)
index 0000000..038c1c5
--- /dev/null
@@ -0,0 +1,14 @@
+s/@/ATSIGN/g
+s/^/@/
+s/$/@/
+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/@//g
+s/ATSIGN/@/g