From 5db911a2b824c4b3e06ca0dfeaecc7aa32be9755 Mon Sep 17 00:00:00 2001 From: Nick Downing Date: Sun, 12 Feb 2017 16:23:13 +1100 Subject: [PATCH] Implement locnnode (former nnode) and extnnode (former xnode) inheriting from a common base nnode, make fnode inherit from cnode, make fasgn inherit from tnode --- c0.h | 40 ++--- c00.c | 36 ++-- c01.c | 204 +++++++++++------------ c02.c | 47 +++--- c03.c | 8 +- c04.c | 32 ++-- c1.h | 106 ++++++------ c10.c | 443 ++++++++++++++++++++++++------------------------- c11.c | 349 ++++++++++++++++++++------------------- c12.c | 471 +++++++++++++++++++++++++++-------------------------- ccom.h | 140 +++++++++------- fields.sed | 7 +- 12 files changed, 968 insertions(+), 915 deletions(-) diff --git a/c0.h b/c0.h index f44e63c..dc66d34 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 struct tree **cp; +extern struct node **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 nnode funcblk; +extern struct locnnode funcblk; extern char cvntab[]; extern char numbuf[64]; extern struct nmlist **memlist; @@ -201,22 +201,22 @@ void putstr __P((int lab, register int max)); void cntstr __P((void)); int getcc __P((void)); int mapch __P((int ac)); -struct tree *tree __P((/*int eflag*/)); +struct node *tree __P((/*int eflag*/)); struct tnode *xprtype __P((void)); char *copnum __P((int len)); /* c01.c */ void build __P((int op)); -void structident __P((register struct tree *p1, register struct nnode *p2)); -struct tree *convert __P((struct tree *p, int t, int cvn, int len)); -void setype __P((register struct tree *p, register int t, register struct tree *newp)); -struct tree *chkfun __P((register struct tree *p)); -struct tree *disarray __P((register struct tree *p)); -void chkw __P((struct tree *p, int okt)); +void structident __P((register struct node *p1, register struct nnode *p2)); +struct node *convert __P((struct node *p, int t, int cvn, int len)); +void setype __P((register struct node *p, register int t, register struct node *newp)); +struct node *chkfun __P((register struct node *p)); +struct node *disarray __P((register struct node *p)); +void chkw __P((struct node *p, int okt)); int lintyp __P((int t)); void werror0 __P((char *s, ...)); void error0 __P((char *s, ...)); -struct tnode *block __P((int op, int t, int *subs, union str *str, struct tree *p1, struct tree *p2)); +struct tnode *block __P((int op, int t, int *subs, union str *str, struct node *p1, struct node *p2)); struct nnode *nblock __P((register struct nmlist *ds)); struct cnode *cblock __P((_INT value)); struct lnode *lblock __P((_LONG lvalue)); @@ -225,10 +225,10 @@ char *Tblock __P((int n)); char *starttree __P((void)); void endtree __P((char *tp)); char *Dblock __P((int n)); -void chklval __P((register struct tree *p)); -int fold __P((int op, register struct tree *p1, struct tree *p2)); +void chklval __P((register struct node *p)); +int fold __P((int op, register struct node *p1, struct node *p2)); int conexp __P((void)); -void assignop __P((int op, register struct tree *p1, register struct tree *p2)); +void assignop __P((int op, register struct node *p1, register struct node *p2)); struct nmlist *gentemp __P((int type)); /* c02.c */ @@ -239,7 +239,7 @@ void strinit __P((struct nmlist *np, int sclass)); void setinit __P((register struct nmlist *np)); void statement __P((void)); int forstmt __P((void)); -struct tree *pexpr __P((/*int eflag*/)); +struct node *pexpr __P((/*int eflag*/)); void pswitch0 __P((void)); void funchead __P((void)); void blockhead __P((void)); @@ -265,14 +265,14 @@ int goodreg __P((struct nmlist *hp)); /* c04.c */ int decref0 __P((register int t)); int incref0 __P((register int t)); -void cbranch0 __P((struct tree *t, int lbl, int cond)); -void rcexpr0 __P((register struct tree *tp)); -void treeout __P((register struct tree *tp, int isstruct)); +void cbranch0 __P((struct node *t, int lbl, int cond)); +void rcexpr0 __P((register struct node *tp)); +void treeout __P((register struct node *tp, int isstruct)); void branch0 __P((int lab)); void label0 __P((int l)); -int plength __P((register struct tree *p)); -int length __P((struct tree *cs)); -int rlength __P((struct tree *cs)); +int plength __P((register struct node *p)); +int length __P((struct node *cs)); +int rlength __P((struct node *cs)); int simplegoto __P((void)); int nextchar __P((void)); int spnextchar __P((void)); diff --git a/c00.c b/c00.c index 17f0ada..94d00fb 100644 --- a/c00.c +++ b/c00.c @@ -18,7 +18,7 @@ int isn0 = 1; int peeksym = -1; int line = 1; -struct nnode funcblk = { { NAME, 0, (int *)NULL, (union str *)NULL }, (struct nmlist *)NULL, 0/*nn_class*/, 0/*nn_regno*/, 0/*nn_offset*/, 0/*nn_nloc*/ }; +struct locnnode funcblk = { { { NAME, 0, (int *)NULL, (union str *)NULL }, (struct nmlist *)NULL, 0/*nn_class*/, 0/*nn_regno*/, 0/*nn_offset*/}, 0/*locnn_nloc*/ }; struct kwtab kwtab[] = { {"int", INT}, @@ -54,8 +54,8 @@ struct kwtab kwtab[] = { {0, 0} }; -struct tree *cmst[CMSIZ]; -struct tree **cp = cmst; +struct node *cmst[CMSIZ]; +struct node **cp = cmst; int Wflag; /* print warning messages */ #if 0 @@ -628,7 +628,7 @@ loop: * "," or ":" because those delimiters are special * in initializer (and some other) expressions. */ -struct tree *tree(/*eflag*/) /*int eflag;*/ { +struct node *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) { - *cp++ = (struct tree *)cblock(cs->hoffset); + *cp++ = (struct node *)cblock(cs->hoffset); goto tand; } if (cs->hclass==0 && cs->htype==0) @@ -664,20 +664,20 @@ advanc: error0("%s undefined; func. %s", cs->name, funcsym ? funcsym->name : "(none)"); } - *cp++ = (struct tree *)nblock(cs); + *cp++ = (struct node *)nblock(cs); goto tand; case FCON: /* *cp++ = fblock(DOUBLE, copnum(cval));*/ - *cp++ = (struct tree *)fblock(isn1++, fcval); + *cp++ = (struct node *)fblock(isn1++, fcval); goto tand; case LCON: - *cp++ = (struct tree *)lblock(lcval); + *cp++ = (struct node *)lblock(lcval); goto tand; case CON: - *cp++ = (struct tree *)cblock(cval); + *cp++ = (struct node *)cblock(cval); goto tand; /* fake a static char array */ @@ -713,7 +713,7 @@ advanc: cs->hclass = STATIC; /* cs->hoffset = cval; *cp++ = block(NAME, unscflg? ARRAY+UNCHAR:ARRAY+CHAR, &nchstr, - (union str *)NULL, (struct tree *)cs, TNULL);*/ + (union str *)NULL, (struct node *)cs, (struct node *)NULL);*/ cs->hflag = 0; cs->htype = unscflg? ARRAY+UNCHAR:ARRAY+CHAR; cs->hstrp = (union str *)&nchstr; @@ -722,7 +722,7 @@ advanc: cs->sparent = 0; cs->hblklev = 0; cs->name = 0; - *cp++ = (struct tree *)nblock(cs); + *cp++ = (struct node *)nblock(cs); tand: if(cp>=cmst+CMSIZ) { @@ -739,7 +739,7 @@ advanc: if (*op != LPARN || andflg) goto syntax; peeksym = o; - *cp++ = (struct tree *)xprtype(); + *cp++ = (struct node *)xprtype(); if ((o=symbol()) != RPARN) goto syntax; o = CAST; @@ -880,8 +880,8 @@ opon1: goto advanc; case MCALL: - *cp++ = (struct tree *)block(NULLOP0, INT, (int *)NULL, - (union str *)NULL, TNULL, TNULL); + *cp++ = (struct node *)block(NULLOP0, INT, (int *)NULL, + (union str *)NULL, (struct node *)NULL, (struct node *)NULL); os = CALL; break; @@ -889,7 +889,7 @@ opon1: case INCAFT: case DECBEF: case DECAFT: - *cp++ = (struct tree *)cblock(1); + *cp++ = (struct node *)cblock(1); break; case LPARN: @@ -911,13 +911,13 @@ syntax: errflush(o); /*if (eflag) endtree(svtree);*/ - return((struct tree *) &garbage); + return((struct node *) &garbage); } struct tnode *xprtype() { struct nmlist typer, absname; int sc; - register struct tree **scp; + register struct node **scp; scp = cp; sc = DEFXTRN; /* will cause error if class mentioned */ @@ -930,7 +930,7 @@ struct tnode *xprtype() { decl1(sc, &typer, 0, &absname); cp = scp; return(block(ETYPE, absname.htype, absname.hsubsp, - absname.hstrp, TNULL, TNULL)); + absname.hstrp, (struct node *)NULL, (struct node *)NULL)); } /*char *copnum(len) int len; { diff --git a/c01.c b/c01.c index 7b6c043..58da0d2 100644 --- a/c01.c +++ b/c01.c @@ -24,7 +24,7 @@ void build(op) int op; { register int t1; int t2, t; - register struct tree *p1, *p2, *p3; + register struct node *p1, *p2, *p3; int dope, leftc, cvn, pcvn; /* @@ -39,7 +39,7 @@ void build(op) int op; { if ((dope&BINARY)!=0) { p2 = chkfun(disarray(*--cp)); if (p2) - t2 = p2->t_type; + t2 = p2->n_type; } p1 = *--cp; /* @@ -48,7 +48,7 @@ void build(op) int op; { if (op==SIZEOF) { struct cnode *p = cblock(length(p1)); p->cn_type = UNSIGN; - *cp++ = (struct tree *)p; + *cp++ = (struct node *)p; return; } if (op!=AMPER) { @@ -56,7 +56,7 @@ void build(op) int op; { if (op!=CALL) p1 = chkfun(p1); } - t1 = p1->t_type; + t1 = p1->n_type; if (t1==CHAR) t1 = INT; else if (t1==UNCHAR) @@ -72,18 +72,18 @@ void build(op) int op; { case CAST: if ((t1&XTYPE)==FUNC || (t1&XTYPE)==ARRAY) error0("Disallowed conversion"); - if (p1->t_type==UNCHAR) { - *cp++ = (struct tree *)block(ETYPE, UNSIGN, (int *)NULL, (union str *)NULL, - TNULL, TNULL); + if (p1->n_type==UNCHAR) { + *cp++ = (struct node *)block(ETYPE, UNSIGN, (int *)NULL, (union str *)NULL, + (struct node *)NULL, (struct node *)NULL); *cp++ = p2; build(CAST); - *cp++ = (struct tree *)cblock(0377); + *cp++ = (struct node *)cblock(0377); build(AND); return; } - if (p2->t_type==CHAR || p2->t_type==UNCHAR) - p2 = (struct tree *)block(PLUS, t2, (int *)NULL, (union str *)NULL, - p2, (struct tree *)cblock(0)); + if (p2->n_type==CHAR || p2->n_type==UNCHAR) + p2 = (struct node *)block(PLUS, t2, (int *)NULL, (union str *)NULL, + p2, (struct node *)cblock(0)); break; /* end of expression */ @@ -93,7 +93,7 @@ void build(op) int op; { /* no-conversion operators */ case QUEST: - if (p2->t_op!=COLON) + if (p2->n_op!=COLON) error0("Illegal conditional"); else if (fold(QUEST, p1, p2)) @@ -108,13 +108,13 @@ void build(op) int op; { * case COMMA: */ case SEQNC: - *cp++ = (struct tree *)block(op, t2, p2->t_subsp, p2->t_strp, p1, p2); + *cp++ = (struct node *)block(op, t2, p2->n_subsp, p2->n_strp, p1, p2); return; case COMMA: case LOGAND: case LOGOR: - *cp++ = (struct tree *)block(op, t, p2->t_subsp, p2->t_strp, p1, p2); + *cp++ = (struct node *)block(op, t, p2->n_subsp, p2->n_strp, p1, p2); return; case EXCLA: @@ -144,18 +144,18 @@ void build(op) int op; { } if ((t1&XTYPE) != FUNC) error0("Call of non-function"); - *cp++ = (struct tree *)block(CALL,decref0(t1),p1->t_subsp,p1->t_strp,p1,p2); + *cp++ = (struct node *)block(CALL,decref0(t1),p1->n_subsp,p1->n_strp,p1,p2); return; case STAR: if ((t1&XTYPE) == FUNC) error0("Illegal indirection"); - *cp++ = (struct tree *)block(STAR, decref0(t1), p1->t_subsp, p1->t_strp, p1, TNULL); + *cp++ = (struct node *)block(STAR, decref0(t1), p1->n_subsp, p1->n_strp, p1, (struct node *)NULL); return; case AMPER: - if (p1->t_op==NAME || p1->t_op==STAR) { - *cp++ = (struct tree *)block(op,incref0(p1->t_type),p1->t_subsp,p1->t_strp,p1,TNULL); + if (p1->n_op==NAME || p1->n_op==STAR) { + *cp++ = (struct node *)block(op,incref0(p1->n_type),p1->n_subsp,p1->n_strp,p1,(struct node *)NULL); return; } error0("Illegal lvalue"); @@ -165,7 +165,7 @@ void build(op) int op; { * a.b goes to (&a)->b */ case DOT: - if (p1->t_op==CALL && t1==STRUCT) { + if (p1->n_op==CALL && t1==STRUCT) { t1 = incref0(t1); setype(p1, t1, p1); } else { @@ -180,7 +180,7 @@ void build(op) int op; { * then * is tacked on to access the member. */ case ARROW: - if (p2->t_op!=NAME || ((struct nnode *)p2)->nn_tr1->hclass!=MOS) { + if (p2->n_op!=NAME || ((struct nnode *)p2)->nn_nmlist->hclass!=MOS) { error0("Illegal structure ref"); *cp++ = p1; return; @@ -188,21 +188,21 @@ void build(op) int op; { #define np2 ((struct nnode *)p2) structident(p1, np2); t2 = np2->nn_type; - if (t2==INT && np2->nn_tr1->hflag&FFIELD) + if (t2==INT && np2->nn_nmlist->hflag&FFIELD) t2 = UNSIGN; t = incref0(t2); chkw(p1, -1); - setype(p1, t, (struct tree *)np2); - *cp++ = (struct tree *)block(PLUS, t, np2->nn_subsp, np2->nn_strp, - p1, (struct tree *)cblock(np2->nn_tr1->hoffset)); + setype(p1, t, (struct node *)np2); + *cp++ = (struct node *)block(PLUS, t, np2->nn_subsp, np2->nn_strp, + p1, (struct node *)cblock(np2->nn_nmlist->hoffset)); build(STAR); - if (np2->nn_tr1->hflag&FFIELD) + if (np2->nn_nmlist->hflag&FFIELD) #if 1 - cp[-1] = (struct tree *)block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, - cp[-1], (struct tree *)np2->nn_tr1->hstrp); + cp[-1] = (struct node *)block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, + cp[-1], (struct node *)np2->nn_nmlist->hstrp); #else - *cp++ = (struct tree *)block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, - *--cp, (struct tree *)np2->nn_tr1->hstrp); + *cp++ = (struct node *)block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL, + *--cp, (struct node *)np2->nn_nmlist->hstrp); #endif return; #undef np2 @@ -222,13 +222,13 @@ void build(op) int op; { t1 = DOUBLE; else if (op==FTOI) t1 = INT; - if (!fold(op, p1, (struct tree *)NULL)) - *cp++ = (struct tree *)block(op, t1, p1->t_subsp, p1->t_strp, p1,TNULL); + if (!fold(op, p1, (struct node *)NULL)) + *cp++ = (struct node *)block(op, t1, p1->n_subsp, p1->n_strp, p1,(struct node *)NULL); return; } cvn = 0; if (t1==STRUCT || t2==STRUCT) { - if (t1!=t2 || p1->t_strp != p2->t_strp) + if (t1!=t2 || p1->n_strp != p2->n_strp) error0("Incompatible structures"); cvn = 0; } else @@ -254,12 +254,12 @@ void build(op) int op; { t = t1; if (op==ASSIGN) { if (cvn==PTI) { - if (t1!=t2 || ((t1&TYPE)==STRUCT && p1->t_strp!=p2->t_strp)) + if (t1!=t2 || ((t1&TYPE)==STRUCT && p1->n_strp!=p2->n_strp)) werror0("mixed pointer assignment"); cvn = leftc = 0; } if ((cvn==ITP || cvn==LTP) - && (p2->t_op!=CON || ((struct cnode *)p2)->cn_value!=0) - && (p2->t_op!=LCON || ((struct lnode *)p2)->ln_lvalue!=0)) { + && (p2->n_op!=CON || ((struct cnode *)p2)->cn_value!=0) + && (p2->n_op!=LCON || ((struct lnode *)p2)->ln_lvalue!=0)) { /* * Allow "i = p" and "p = i" with a warning, where * i is some form of integer (not 0) and p is a @@ -307,8 +307,8 @@ void build(op) int op; { */ if (op==COLON && (cvn==ITP || cvn==LTP)) { p3 = leftc? p1: p2; - if ((p3->t_op!=CON || ((struct cnode *)p3)->cn_value!=0) - && (p3->t_op!=LCON || ((struct lnode *)p3)->ln_lvalue!=0)) { + if ((p3->n_op!=CON || ((struct cnode *)p3)->cn_value!=0) + && (p3->n_op!=LCON || ((struct lnode *)p3)->ln_lvalue!=0)) { werror0("illegal combination of pointer and integer, op :"); if (cvn==ITP) cvn = leftc = 0; @@ -332,8 +332,8 @@ void build(op) int op; { cvn = 0; if (op==MINUS) { pcvn++; - p1 = (struct tree *)block(ITOL, LONG, (int *)NULL, (union str *)NULL, p1, TNULL); - p2 = (struct tree *)block(ITOL, LONG, (int *)NULL, (union str *)NULL, p2, TNULL); + p1 = (struct node *)block(ITOL, LONG, (int *)NULL, (union str *)NULL, p1, (struct node *)NULL); + p2 = (struct node *)block(ITOL, LONG, (int *)NULL, (union str *)NULL, p2, (struct node *)NULL); t = LONG; } else { if (t1!=t2 || (t1!=(PTR+CHAR) && t1!=(PTR+UNCHAR))) @@ -343,8 +343,8 @@ void build(op) int op; { if (cvn) { if ((cvn==ITP || cvn==LTP) && (opdope0[op]&PCVOK)==0) { p3 = leftc? p1: p2; - if ((p3->t_op!=CON || ((struct cnode *)p3)->cn_value!=0) - && (p3->t_op!=LCON || ((struct lnode *)p3)->ln_lvalue!=0)) + if ((p3->n_op!=CON || ((struct cnode *)p3)->cn_value!=0) + && (p3->n_op!=LCON || ((struct lnode *)p3)->ln_lvalue!=0)) cvn = XX; else cvn = 0; @@ -366,13 +366,13 @@ void build(op) int op; { t = INT; if (op==CAST) { /* could the below be an oversight? gcc notes rhs always true */ - if (t!=DOUBLE /*&& (t!=INT || p2->t_type!=CHAR || p2->t_type!=UNCHAR)*/) { - p2->t_type = t; - p2->t_subsp = p1->t_subsp; - p2->t_strp = p1->t_strp; + if (t!=DOUBLE /*&& (t!=INT || p2->n_type!=CHAR || p2->n_type!=UNCHAR)*/) { + p2->n_type = t; + p2->n_subsp = p1->n_subsp; + p2->n_strp = p1->n_strp; } - if (t==INT && p1->t_type==CHAR) - p2 = (struct tree *)block(ITOC, INT, (int *)NULL, (union str *)NULL, p2, TNULL); + if (t==INT && p1->n_type==CHAR) + p2 = (struct node *)block(ITOC, INT, (int *)NULL, (union str *)NULL, p2, (struct node *)NULL); *cp++ = p2; return; } @@ -380,7 +380,7 @@ void build(op) int op; { t2 = plength(((struct tnode *)p1)->tn_tr1); if (fold(op, p1, p2)==0) { p3 = leftc?p2:p1; - *cp++ = (struct tree *)block(op, t, p3->t_subsp, p3->t_strp, p1, p2); + *cp++ = (struct node *)block(op, t, p3->n_subsp, p3->n_strp, p1, p2); } if (pcvn) { p1 = *--cp; @@ -388,17 +388,17 @@ void build(op) int op; { } } -void structident(p1, p2) register struct tree *p1; register struct nnode *p2; { +void structident(p1, p2) register struct node *p1; register struct nnode *p2; { register struct nmlist *np, *nporig; int vartypes = 0, namesame = 1; - np = nporig = p2->nn_tr1; + np = nporig = p2->nn_nmlist; for (;;) { - if (namesame && p1->t_type==STRUCT+PTR && p1->t_strp == np->sparent) { + if (namesame && p1->n_type==STRUCT+PTR && p1->n_strp == np->sparent) { p2->nn_type = np->htype; p2->nn_strp = np->hstrp; p2->nn_subsp = np->hsubsp; - p2->nn_tr1 = np; + p2->nn_nmlist = np; return; } np = np->nextnm; @@ -423,7 +423,7 @@ void structident(p1, p2) register struct tree *p1; register struct nnode *p2; { /* * Generate the appropriate conversion operator. */ -struct tree *convert(p, t, cvn, len) struct tree *p; int t; int cvn; int len; { +struct node *convert(p, t, cvn, len) struct node *p; int t; int cvn; int len; { register int op; if (cvn==0) @@ -432,9 +432,9 @@ struct tree *convert(p, t, cvn, len) struct tree *p; int t; int cvn; int len; { if (opdope0[op]&BINARY) { if (len==0) error0("Illegal conversion"); - return((struct tree *)block(op, t, (int *)NULL, (union str *)NULL, p, (struct tree *)cblock(len))); + return((struct node *)block(op, t, (int *)NULL, (union str *)NULL, p, (struct node *)cblock(len))); } - return((struct tree *)block(op, t, (int *)NULL, (union str *)NULL, p, TNULL)); + return((struct node *)block(op, t, (int *)NULL, (union str *)NULL, p, (struct node *)NULL)); } /* @@ -444,16 +444,16 @@ struct tree *convert(p, t, cvn, len) struct tree *p; int t; int cvn; int len; { * type at. * Used with structure references. */ -void setype(p, t, newp) register struct tree *p; register int t; register struct tree *newp; { +void setype(p, t, newp) register struct node *p; register int t; register struct node *newp; { for (;; p = ((struct tnode *)p)->tn_tr1) { - p->t_subsp = newp->t_subsp; - p->t_strp = newp->t_strp; - p->t_type = t; - if (p->t_op==AMPER) + p->n_subsp = newp->n_subsp; + p->n_strp = newp->n_strp; + p->n_type = t; + if (p->n_op==AMPER) t = decref0(t); - else if (p->t_op==STAR) + else if (p->n_op==STAR) t = incref0(t); - else if (p->t_op!=PLUS) + else if (p->n_op!=PLUS) break; } } @@ -462,11 +462,11 @@ void setype(p, t, newp) register struct tree *p; register int t; register struct * A mention of a function name is turned into * a pointer to that function. */ -struct tree *chkfun(p) register struct tree *p; { +struct node *chkfun(p) register struct node *p; { register int t; - if (((t = p->t_type)&XTYPE)==FUNC && p->t_op!=ETYPE) - return((struct tree *)block(AMPER,incref0(t),p->t_subsp,p->t_strp,p,TNULL)); + if (((t = p->n_type)&XTYPE)==FUNC && p->n_op!=ETYPE) + return((struct node *)block(AMPER,incref0(t),p->n_subsp,p->n_strp,p,(struct node *)NULL)); return(p); } @@ -474,17 +474,17 @@ struct tree *chkfun(p) register struct tree *p; { * A mention of an array is turned into * a pointer to the base of the array. */ -struct tree *disarray(p) register struct tree *p; { +struct node *disarray(p) register struct node *p; { register int t; if (p==NULL) return(p); /* check array & not MOS and not typer */ - if (((t = p->t_type)&XTYPE)!=ARRAY - || p->t_op==NAME && ((struct nnode *)p)->nn_tr1->hclass==MOS - || p->t_op==ETYPE) + if (((t = p->n_type)&XTYPE)!=ARRAY + || p->n_op==NAME && ((struct nnode *)p)->nn_nmlist->hclass==MOS + || p->n_op==ETYPE) return(p); - p->t_subsp++; + p->n_subsp++; *cp++ = p; setype(p, decref0(t), p); build(AMPER); @@ -497,8 +497,8 @@ struct tree *disarray(p) register struct tree *p; { * okt might be nonexistent or 'long' * (e.g. for <<). */ -void chkw(p, okt) struct tree *p; int okt; { - register int t = p->t_type; +void chkw(p, okt) struct node *p; int okt; { + register int t = p->n_type; if (t == UNLONG) t = LONG; @@ -581,7 +581,7 @@ void error0(s, va_alist) char *s; va_dcl * setting the operator, type, dimen/struct table ptrs, * and the operands. */ -struct tnode *block(op, t, subs, str, p1, p2) int op; int t; int *subs; union str *str; struct tree *p1; struct tree *p2; { +struct tnode *block(op, t, subs, str, p1, p2) int op; int t; int *subs; union str *str; struct node *p1; struct node *p2; { register struct tnode *p; p = (struct tnode *)Tblock(sizeof(struct tnode)); @@ -598,26 +598,28 @@ struct tnode *block(op, t, subs, str, p1, p2) int op; int t; int *subs; union st } struct nnode *nblock(ds) register struct nmlist *ds; { - /* return(block(NAME, ds->htype, ds->hsubsp, ds->hstrp, (struct tree *)ds, TNULL));*/ + /* return(block(NAME, ds->htype, ds->hsubsp, ds->hstrp, (struct node *)ds, (struct node *)NULL));*/ struct nnode *p; if (ds->hclass == EXTERN) { -#define xp (*(struct xnode **)&p) - xp = (struct xnode *)Tblock(sizeof(struct xnode)); - xp->xn_name = Tblock((strlen(ds->name)+2+LNCPW-1) & ~(LNCPW-1)); - xp->xn_name[0] = '_'; - strcpy(xp->xn_name + 1, ds->name); -#undef xp +#define extp (*(struct extnnode **)&p) + extp = (struct extnnode *)Tblock(sizeof(struct extnnode)); + extp->extnn_name = Tblock((strlen(ds->name)+2+LNCPW-1) & ~(LNCPW-1)); + extp->extnn_name[0] = '_'; + strcpy(extp->extnn_name + 1, ds->name); +#undef extp } else { - p = (struct nnode *)Tblock(sizeof(struct nnode)); - p->nn_nloc = ds->hoffset; +#define locp (*(struct locnnode **)&p) + locp = (struct locnnode *)Tblock(sizeof(struct locnnode)); + locp->locnn_nloc = ds->hoffset; +#undef locp } p->nn_op = NAME; p->nn_type = ds->htype; p->nn_subsp = ds->hsubsp; p->nn_strp = ds->hstrp; - p->nn_tr1 = ds; + p->nn_nmlist = ds; p->nn_class = ds->hclass==0?STATIC:ds->hclass; p->nn_regno = 0; p->nn_offset = 0; @@ -747,10 +749,10 @@ char *Dblock(n) int n; { /* * Check that a tree can be used as an lvalue. */ -void chklval(p) register struct tree *p; { - if (p->t_op==FSEL) +void chklval(p) register struct node *p; { + if (p->n_op==FSEL) p = ((struct tnode *)p)->tn_tr1; - if (p->t_op!=NAME && p->t_op!=STAR) + if (p->n_op!=NAME && p->n_op!=STAR) error0("Lvalue required"); } @@ -760,20 +762,20 @@ void chklval(p) register struct tree *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 struct tree *p1; struct tree *p2; { +int fold(op, p1, p2) int op; register struct node *p1; struct node *p2; { register int v1, v2; int unsignf; - if (p1->t_op!=CON) + if (p1->n_op!=CON) return(0); #define cp1 ((struct cnode *)p1) unsignf = cp1->cn_type==UNSIGN; unsignf |= cp1->cn_type==UNLONG; if (op==QUEST) { #define tp2 ((struct tnode *)p2) - if (tp2->tn_tr1->t_op==CON && tp2->tn_tr2->t_op==CON) { + if (tp2->tn_tr1->n_op==CON && tp2->tn_tr2->n_op==CON) { cp1->cn_value = cp1->cn_value? ((struct cnode *)tp2->tn_tr1)->cn_value: ((struct cnode *)tp2->tn_tr2)->cn_value; - *cp++ = (struct tree *)cp1; + *cp++ = (struct node *)cp1; cp1->cn_type = tp2->tn_type; return(1); } @@ -781,7 +783,7 @@ int fold(op, p1, p2) int op; register struct tree *p1; struct tree *p2; { #undef tp2 } if (p2) { - if (p2->t_op!=CON) + if (p2->n_op!=CON) return(0); #define cp2 ((struct cnode *)p2) v2 = cp2->cn_value; @@ -918,7 +920,7 @@ int fold(op, p1, p2) int op; register struct tree *p1; struct tree *p2; { return(0); } cp1->cn_value = v1; - *cp++ = (struct tree *)cp1; + *cp++ = (struct node *)cp1; if (unsignf) cp1->cn_type = UNSIGN; return(1); @@ -930,11 +932,11 @@ int fold(op, p1, p2) int op; register struct tree *p1; struct tree *p2; { * for example an array bound or a case value. */ int conexp() { - register struct tree *t; + register struct node *t; char *st = starttree(); initflg++; if (t = tree(/*1*/)) - if (t->t_op != CON) + if (t->n_op != CON) error0("Constant required"); if (!t) abort(); /* don't think this can ever happen */ initflg--; @@ -945,11 +947,11 @@ int conexp() { /* * Handle peculiar assignment ops that need a temporary. */ -void assignop(op, p1, p2) int op; register struct tree *p1; register struct tree *p2; { +void assignop(op, p1, p2) int op; register struct node *p1; register struct node *p2; { register struct nmlist *np; op += PLUS - ASPLUS; - if (p1->t_op==NAME) { + if (p1->n_op==NAME) { *cp++ = p1; *cp++ = p1; *cp++ = p2; @@ -957,14 +959,14 @@ void assignop(op, p1, p2) int op; register struct tree *p1; register struct tree build(ASSIGN); return; } - np = gentemp(incref0(p1->t_type)); - *cp++ = (struct tree *)nblock(np); + np = gentemp(incref0(p1->n_type)); + *cp++ = (struct node *)nblock(np); *cp++ = p1; build(AMPER); build(ASSIGN); - *cp++ = (struct tree *)nblock(np); + *cp++ = (struct node *)nblock(np); build(STAR); - *cp++ = (struct tree *)nblock(np); + *cp++ = (struct node *)nblock(np); build(STAR); *cp++ = p2; build(op); @@ -986,7 +988,7 @@ struct nmlist *gentemp(type) int type; { tp->hsubsp = NULL; tp->hstrp = NULL; tp->hblklev = blklev; - autolen -= rlength((struct tree *)tp); + autolen -= rlength((struct node *)tp); tp->hoffset = autolen; if (autolen < maxauto) maxauto = autolen; diff --git a/c02.c b/c02.c index f191e01..5c5ef01 100644 --- a/c02.c +++ b/c02.c @@ -46,8 +46,9 @@ void extdef() { if ((ds->htype&XTYPE)==FUNC) { if ((peeksym=symbol())==LBRACE || peeksym==KEYW || (peeksym==NAME && csym->hclass==TYPEDEF)) { - funcblk.nn_type = decref0(ds->htype); - funcblk.nn_strp = ds->hstrp; + /* create a fake local variable of same type as function's return type */ + funcblk.locnn_type = decref0(ds->htype); + funcblk.locnn_strp = ds->hstrp; setinit(ds); outcode("BS", SYMDEF, sclass==EXTERN?ds->name:""); cfunc(); @@ -57,7 +58,7 @@ void extdef() { error0("Inappropriate parameters"); } else if ((o=symbol())==COMMA || o==SEMI) { peeksym = o; - o = (length((struct tree *)ds)+ALIGN) & ~ALIGN; + o = (length((struct node *)ds)+ALIGN) & ~ALIGN; if (sclass==STATIC) { setinit(ds); outcode("BSBBSBN", SYMDEF, "", BSS, NLABEL, ds->name, SSPACE, o); @@ -132,7 +133,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; - struct tree *s; + struct node *s; np = *anp; realtype = np.htype; @@ -141,7 +142,7 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; { isarray++; else flex = 0; - width = length((struct tree *)&np); + width = length((struct node *)&np); nel = 1; /* * If it's an array, find the number of elements. @@ -156,7 +157,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((struct tree *)&np); + o = length((struct node *)&np); nel = (unsigned)width/o; width = o; } @@ -190,18 +191,18 @@ int cinit(anp, flex, sclass) struct nmlist *anp; int flex; int sclass; { initflg = 0; if (np.hflag&FFIELD) error0("No field initialization"); - *cp++ = (struct tree *)nblock(&np); + *cp++ = (struct node *)nblock(&np); *cp++ = s; build(ASSIGN); if (sclass==AUTO||sclass==REG) rcexpr0(*--cp); else if (sclass==ENUMCON) { - if (s->t_op!=CON) + if (s->n_op!=CON) error0("Illegal enum constant for %s", anp->name); anp->hoffset = ((struct cnode *)s)->cn_value; } else - rcexpr0((struct tree *)block(INIT,np.htype,(int *)NULL, - (union str *)NULL, ((struct tnode *)(*--cp))->tn_tr2, TNULL)); + rcexpr0((struct node *)block(INIT,np.htype,(int *)NULL, + (union str *)NULL, ((struct tnode *)(*--cp))->tn_tr2, (struct node *)NULL)); endtree(st); } ninit++; @@ -351,7 +352,7 @@ stmt: case IF: { register int o2; - register struct tree *np; + register struct node *np; char *st = starttree(); np = pexpr(/*1*/); @@ -477,7 +478,7 @@ stmt: goto stmt; case SWITCH: { - register struct tree *np; + register struct node *np; register char *st; o1 = brklab; @@ -485,7 +486,7 @@ stmt: st = starttree(); np = pexpr(/*0*/); chkw(np, -1); - rcexpr0((struct tree *)block(RFORCE,0,(int *)NULL,(union str *)NULL,np,TNULL)); + rcexpr0((struct node *)block(RFORCE,0,(int *)NULL,(union str *)NULL,np,(struct node *)NULL)); endtree(st); pswitch0(); brklab = o1; @@ -568,7 +569,7 @@ syntax: */ int forstmt() { register int o; - register struct tree *st; + register struct node *st; register int l; char *ss; @@ -628,16 +629,16 @@ int forstmt() { * A parenthesized expression, * as after "if". */ -struct tree *pexpr(/*eflag*/) /*int eflag;*/ { +struct node *pexpr(/*eflag*/) /*int eflag;*/ { register int o; - register struct tree *t; + register struct node *t; if ((o=symbol())!=LPARN) goto syntax; t = tree(/*eflag*/); if ((o=symbol())!=RPARN) goto syntax; - if (t->t_type==VOID) + if (t->n_type==VOID) error0("Illegal use of void"); return(t); syntax: @@ -685,7 +686,7 @@ void pswitch0() { * Structure resembling a block for a register variable. */ struct nmlist hreg = { REG, 0, 0, NULL, NULL, 0 }; -struct nnode areg = { { NAME, 0, (int *)NULL, (union str *)NULL }, &hreg, 0/*nn_class*/, 0/*nn_regno*/, 0/*nn_offset*/, 0/*nn_nlock*/ }; +struct locnnode areg = { { { NAME, 0, (int *)NULL, (union str *)NULL }, &hreg, 0/*nn_class*/, 0/*nn_regno*/, 0/*nn_offset*/}, 0/*locnn_nloc*/ }; void funchead() { register int pl; register struct nmlist *cs; @@ -703,13 +704,13 @@ void funchead() { cs->htype -= (ARRAY-PTR); /* set ptr */ cs->hsubsp++; /* pop dims */ } - pl += rlength((struct tree *)cs); + pl += rlength((struct node *)cs); if (cs->hclass==AREG && (hreg.hoffset=goodreg(cs))>=0) { st = starttree(); - *cp++ = (struct tree *)&areg; - *cp++ = (struct tree *)nblock(cs); - areg.nn_type = cs->htype; - areg.nn_strp = cs->hstrp; + *cp++ = (struct node *)&areg; + *cp++ = (struct node *)nblock(cs); + areg.locnn_type = cs->htype; + areg.locnn_strp = cs->hstrp; cs->hclass = AUTO; build(ASSIGN); rcexpr0(*--cp); diff --git a/c03.c b/c03.c index 57ac212..80971f1 100644 --- 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((struct tree *)tptr); + o = length((struct node *)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((struct tree *)dsym); + elsize = length((struct node *)dsym); if ((peeksym = symbol())==COLON) { elsize = 0; peeksym = -1; @@ -485,7 +485,7 @@ int decl1(askw, atptr, offset, absname) int askw; struct nmlist *atptr; int offs if (skw==AUTO) { /* if (STAUTO < 0) { */ /*fprintf(stderr, "%s autolen %d -> ", dsym->name, autolen);*/ - autolen -= rlength((struct tree *)dsym); + autolen -= rlength((struct node *)dsym); dsym->hoffset = autolen; if (autolen < maxauto) maxauto = autolen; @@ -507,7 +507,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((struct tree *)dsym)); + rlength((struct node *)dsym)); outcode("B", PROG); isinit = 0; } else if (skw==REG && isinit) { diff --git a/c04.c b/c04.c index 9b25479..f928733 100644 --- a/c04.c +++ b/c04.c @@ -37,7 +37,7 @@ int incref0(t) register int t; { * 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) struct tree *t; int lbl; int cond; { +void cbranch0(t, lbl, cond) struct node *t; int lbl; int cond; { #if 1 /* one-pass version */ long outloc; @@ -61,14 +61,14 @@ void cbranch0(t, lbl, cond) struct tree *t; int lbl; int cond; { /* * Write out a tree. */ -void rcexpr0(tp) register struct tree *tp; { +void rcexpr0(tp) register struct node *tp; { #if 1 /* one-pass version */ long outloc; #endif /* * Special optimization */ - if (tp->t_op==INIT && ((struct tnode *)tp)->tn_tr1->t_op==CON) { + if (tp->n_op==INIT && ((struct tnode *)tp)->tn_tr1->n_op==CON) { #define ttp ((struct tnode *)tp) if (ttp->tn_type==CHAR || ttp->tn_type==UNCHAR) { outcode("B1N0", BDATA, ((struct cnode *)ttp->tn_tr1)->cn_value); @@ -98,7 +98,7 @@ void rcexpr0(tp) register struct tree *tp; { } #if 0 -void treeout(tp, isstruct) register struct tree *tp; int isstruct; { +void treeout(tp, isstruct) register struct node *tp; int isstruct; { register struct nmlist *hp; register int nextisstruct; @@ -197,14 +197,14 @@ 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 struct tree *p; { +int plength(p) register struct node *p; { register int t, l; - if (p==0 || ((t=p->t_type)&~TYPE) == 0) /* not a reference */ + if (p==0 || ((t=p->n_type)&~TYPE) == 0) /* not a reference */ return(1); - p->t_type = decref0(t); + p->n_type = decref0(t); l = length(p); - p->t_type = t; + p->n_type = t; return(l); } @@ -212,17 +212,17 @@ int plength(p) register struct tree *p; { * return the number of bytes in the object * whose tree node is acs. */ -int length(cs) struct tree *cs; { +int length(cs) struct node *cs; { register int t, elsz; long n; int nd; - t = cs->t_type; + t = cs->n_type; n = 1; nd = 0; while ((t&XTYPE) == ARRAY) { t = decref0(t); - n *= cs->t_subsp[nd++]; + n *= cs->n_subsp[nd++]; } if ((t&~TYPE)==FUNC) return(0); @@ -258,7 +258,7 @@ int length(cs) struct tree *cs; { break; case STRUCT: - if ((elsz = cs->t_strp->S.ssize) == 0) + if ((elsz = cs->n_strp->S.ssize) == 0) error0("Undefined structure"); break; default: @@ -274,7 +274,7 @@ int length(cs) struct tree *cs; { /* * The number of bytes in an object, rounded up to a word. */ -int rlength(cs) struct tree *cs; { +int rlength(cs) struct node *cs; { return((length(cs)+ALIGN) & ~ALIGN); } @@ -344,14 +344,14 @@ void chconbrk(l) int l; { * The goto statement. */ void dogoto() { - register struct tree *np; + register struct node *np; register char *st; st = starttree(); *cp++ = tree(/*0*/); build(STAR); chkw(np = *--cp, -1); - rcexpr0((struct tree *)block(JUMP, 0, (int *)NULL, (union str *)NULL, np, TNULL)); + rcexpr0((struct node *)block(JUMP, 0, (int *)NULL, (union str *)NULL, np, (struct node *)NULL)); endtree(st); } @@ -364,7 +364,7 @@ void doret() { register char *st; st = starttree(); - *cp++ = (struct tree *)&funcblk; + *cp++ = (struct node *)&funcblk; *cp++ = tree(/*0*/); build(ASSIGN); cp[-1] = ((struct tnode *)cp[-1])->tn_tr2; diff --git a/c1.h b/c1.h index 4980780..5a8c64f 100644 --- a/c1.h +++ b/c1.h @@ -101,7 +101,7 @@ extern int opdope1[]; extern char *opntab[]; extern int nstack; extern int nfloat; -extern struct nnode sfuncr; +extern struct locnnode sfuncr; extern char *funcbase; extern char *curbase; extern char *coremax; @@ -113,21 +113,21 @@ extern jmp_buf jmpbuf; /*long ftell();*/ /*char *sbrk();*/ /*struct optab *match();*/ -/*struct tree *optim();*/ -/*struct tree *unoptim();*/ -/*struct tree *pow2();*/ -/*struct tree *tnode();*/ -/*struct tree *sdelay();*/ -/*struct tree *ncopy();*/ -/*struct tree *getblk();*/ -/*struct tree *strfunc();*/ -/*struct tree *isconstant();*/ -/*struct tree *tconst();*/ -/*struct tree *hardlongs();*/ -/*struct tree *lconst();*/ -/*struct tree *acommute();*/ -/*struct tree *lvfield();*/ -/*struct tree *paint();*/ +/*struct node *optim();*/ +/*struct node *unoptim();*/ +/*struct node *pow2();*/ +/*struct node *tnode();*/ +/*struct node *sdelay();*/ +/*struct node *ncopy();*/ +/*struct node *getblk();*/ +/*struct node *strfunc();*/ +/*struct node *isconstant();*/ +/*struct node *tconst();*/ +/*struct node *hardlongs();*/ +/*struct node *lconst();*/ +/*struct node *acommute();*/ +/*struct node *lvfield();*/ +/*struct node *paint();*/ /*long ftell();*/ /* @@ -141,7 +141,7 @@ struct acl { int nextl; int nextn; struct tnode *nlist[LSTSIZ]; - struct tree *llist[LSTSIZ+1]; + struct node *llist[LSTSIZ+1]; }; #endif @@ -155,39 +155,39 @@ struct acl { /* c10.c */ int main __P((int argc, char *argv[])); -struct optab *match __P((struct tree *tree, struct table *table, int nrleft, int nocvt)); -int rcexpr1 __P((struct tree *atree, struct table *atable, int reg)); -int cexpr __P((register struct tree *tree, struct table *table, int areg)); -int reorder __P((struct tree **treep, struct table *table, int reg)); -int sreorder __P((struct tree **treep, struct table *table, int reg, int recurf)); -int delay __P((struct tree **treep, struct table *table, int reg)); -struct tree *sdelay __P((struct tree **ap)); -struct tree *paint __P((register struct tree *tp, register int type)); +struct optab *match __P((struct node *tree, struct table *table, int nrleft, int nocvt)); +int rcexpr1 __P((struct node *atree, struct table *atable, int reg)); +int cexpr __P((register struct node *tree, struct table *table, int areg)); +int reorder __P((struct node **treep, struct table *table, int reg)); +int sreorder __P((struct node **treep, struct table *table, int reg, int recurf)); +int delay __P((struct node **treep, struct table *table, int reg)); +struct node *sdelay __P((struct node **ap)); +struct node *paint __P((register struct node *tp, register int type)); struct nnode *ncopy __P((register struct nnode *p)); -int chkleaf __P((register struct tree *tree, struct table *table, int reg)); -int comarg __P((register struct tree *tree, int *flagp)); -struct tree *strfunc __P((register struct tree *tp)); -void doinit __P((register int type, register struct tree *tree)); -void movreg __P((int r0, int r1, struct tree *tree)); +int chkleaf __P((register struct node *tree, struct table *table, int reg)); +int comarg __P((register struct node *tree, int *flagp)); +struct node *strfunc __P((register struct node *tp)); +void doinit __P((register int type, register struct node *tree)); +void movreg __P((int r0, int r1, struct node *tree)); /* c11.c */ -int degree __P((register struct tree *t)); -void pname __P((register struct tree *p, int flag)); +int degree __P((register struct node *t)); +void pname __P((register struct node *p, int flag)); void pbase __P((register struct nnode *p)); -int xdcalc __P((register struct tree *p, int nrleft)); -int dcalc __P((register struct tree *p, int nrleft)); -int notcompat __P((register struct tree *p, int ast, int deg, int op)); +int xdcalc __P((register struct node *p, int nrleft)); +int dcalc __P((register struct node *p, int nrleft)); +int notcompat __P((register struct node *p, int ast, int deg, int op)); int prins __P((int op, int c, struct instab *itable, int lbl)); -int collcon __P((register struct tree *p)); -int isfloat __P((register struct tree *t)); -int oddreg __P((register struct tree *t, register int reg)); +int collcon __P((register struct node *p)); +int isfloat __P((register struct node *t)); +int oddreg __P((register struct node *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 struct tnode *tree)); struct tnode *pow2 __P((register struct tnode *tree)); -void cbranch1 __P((struct tree *atree, register int lbl, int cond, register int reg)); +void cbranch1 __P((struct node *atree, register int lbl, int cond, register int reg)); void branch1 __P((int lbl, int aop, int c)); void longrel __P((struct tnode *atree, int lbl, int cond, int reg)); int xlongrel __P((int f)); @@ -203,23 +203,23 @@ int decref1 __P((register int t)); int incref1 __P((register int t)); /* c12.c */ -struct tree *optim __P((register struct tree *tree)); -struct tree *binoptim __P((register struct tree *tree)); -struct tree *unoptim __P((register struct tree *tree)); -struct tree *lvfield __P((register struct tnode *t)); -struct tree *acommute __P((register struct tree *tree)); -int sideeffects __P((register struct tree *tp)); +struct node *optim __P((register struct node *tree)); +struct node *binoptim __P((register struct node *tree)); +struct node *unoptim __P((register struct node *tree)); +struct node *lvfield __P((register struct tnode *t)); +struct node *acommute __P((register struct node *tree)); +int sideeffects __P((register struct node *tp)); void distrib __P((struct acl *list)); -void squash __P((struct tree **p, struct tree **maxp)); +void squash __P((struct node **p, struct node **maxp)); void _const __P((int op, register _INT *vp, _INT v, int type)); -struct lnode *lconst __P((int op, register struct tree *lp, register struct tree *rp)); -void insert __P((int op, register struct tree *tree, register struct acl *list)); -struct tnode *tnode __P((int op, int type, struct tree *tr1, struct tree *tr2)); +struct lnode *lconst __P((int op, register struct node *lp, register struct node *rp)); +void insert __P((int op, register struct node *tree, register struct acl *list)); +struct tnode *tnode __P((int op, int type, struct node *tr1, struct node *tr2)); struct cnode *tconst __P((int val, int type)); -struct tree *getblk __P((int size)); +struct node *getblk __P((int size)); int islong __P((int t)); -struct tree *isconstant __P((register struct tree *t)); -struct tree *hardlongs __P((register struct tree *t)); -int uns __P((struct tree *tp)); +struct cnode *isconstant __P((register struct node *t)); +struct node *hardlongs __P((register struct node *t)); +int uns __P((struct node *tp)); #endif diff --git a/c10.c b/c10.c index 212007a..8e93787 100644 --- a/c10.c +++ b/c10.c @@ -14,7 +14,7 @@ static char sccsid[] = "@(#)c10.c 2.1 (2.11BSD GTE) 10/4/94"; #include "c1.h" #ifdef DEBUG -#define dbprint(op) fprintf(temp_fp[temp_fi], /*printf(*/" / %s", opntab[op]) +#define dbprint(op) fprintf(temp_fp[temp_fi], " / %s", opntab[op]) #else #define dbprint(op) /* */ #endif @@ -30,7 +30,7 @@ char notrel[] = { NEQUAL, EQUAL, GREAT, GREATEQ, LESS, struct cnode czero = { { CON, INT, (int *)NULL, (union str *)NULL }, 0}; struct cnode cone = { { CON, INT, (int *)NULL, (union str *)NULL }, 1}; -struct nnode sfuncr = { { NAME, STRUCT, (int *)NULL, (union str *)NULL }, (struct nmlist *)NULL, STATIC, 0, 0, 0 }; +struct locnnode sfuncr = { { { NAME, STRUCT, (int *)NULL, (union str *)NULL }, (struct nmlist *)NULL, STATIC/*nn_class*/, 0/*nn_regno*/, 0/*nn_offset*/ }, 0/*locnn_nloc*/ }; struct table *cregtab; int nreg = 3; @@ -63,11 +63,11 @@ int main(argc, argv) int argc; char *argv[]; { * pulls in the floating-point part of printf. */ if (nfloat) - fprintf(temp_fp[temp_fi], /*printf(*/".globl fltused\n"); + fprintf(temp_fp[temp_fi], ".globl fltused\n"); /* * tack on the string file. */ - fprintf(temp_fp[temp_fi], /*printf(*/".globl\n.data\n"); + fprintf(temp_fp[temp_fi], ".globl\n.data\n"); if (*argv[2] != '-') { if (freopen(argv[2], "r", stdin)==NULL) { error1("Missing temp file"); @@ -90,19 +90,19 @@ 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(tree, table, nrleft, nocvt) struct tree *tree; struct table *table; int nrleft; int nocvt; { +struct optab *match(tree, table, nrleft, nocvt) struct node *tree; struct table *table; int nrleft; int nocvt; { #define NOCVL 1 #define NOCVR 2 int op, d1, d2, dope; - struct tree *p2; - register struct tree *p1; + struct node *p2; + register struct node *p1; register struct optab *opt; if (tree==NULL) return(NULL); if (table==lsptab) table = sptab; - if ((op = tree->t_op)==0) + if ((op = tree->n_op)==0) return(0); dope = opdope1[op]; if ((dope&LEAF) == 0) @@ -120,16 +120,16 @@ struct optab *match(tree, table, nrleft, nocvt) struct tree *tree; struct table * the converted int in a register by * movf double,fr0; movfi fr0,int . */ - if (opdope1[p2->t_op]&CNVRT && (nocvt&NOCVR)==0 - && (opdope1[((struct tnode *)p2)->tn_tr1->t_op]&CNVRT)==0) { + if (opdope1[p2->n_op]&CNVRT && (nocvt&NOCVR)==0 + && (opdope1[((struct tnode *)p2)->tn_tr1->n_op]&CNVRT)==0) { ttree->tn_tr2 = ((struct tnode *)p2)->tn_tr1; - if (opt = match((struct tree *)ttree, table, nrleft, NOCVL)) + if (opt = match((struct node *)ttree, table, nrleft, NOCVL)) return(opt); ttree->tn_tr2 = p2; - } else if (opdope1[p1->t_op]&CNVRT && (nocvt&NOCVL)==0 - && (opdope1[((struct tnode *)p1)->tn_tr1->t_op]&CNVRT)==0) { + } else if (opdope1[p1->n_op]&CNVRT && (nocvt&NOCVL)==0 + && (opdope1[((struct tnode *)p1)->tn_tr1->n_op]&CNVRT)==0) { ttree->tn_tr1 = ((struct tnode *)p1)->tn_tr1; - if (opt = match((struct tree *)ttree, table, nrleft, NOCVR)) + if (opt = match((struct node *)ttree, table, nrleft, NOCVR)) return(opt); ttree->tn_tr1 = p1; } @@ -141,13 +141,13 @@ struct optab *match(tree, table, nrleft, nocvt) struct tree *tree; struct table return(0); for (opt = table->tabp; opt->tabdeg1!=0; opt++) { if (d1 > (opt->tabdeg1&077) - || (opt->tabdeg1 >= 0100 && (p1->t_op != STAR))) + || (opt->tabdeg1 >= 0100 && (p1->n_op != STAR))) continue; if (notcompat(p1, opt->tabtyp1, opt->tabdeg1, op)) continue; if ((opdope1[op]&BINARY)!=0 && p2!=0) { if (d2 > (opt->tabdeg2&077) - || (opt->tabdeg2 >= 0100) && (p2->t_op != STAR) ) + || (opt->tabdeg2 >= 0100) && (p2->n_op != STAR) ) continue; if (notcompat(p2,opt->tabtyp2, opt->tabdeg2, 0)) continue; @@ -180,10 +180,10 @@ struct optab *match(tree, table, nrleft, nocvt) struct tree *tree; struct table * A number of special cases are recognized, and * there is an interaction with the optimizer routines. */ -int rcexpr1(atree, atable, reg) struct tree *atree; struct table *atable; int reg; { +int rcexpr1(atree, atable, reg) struct node *atree; struct table *atable; int reg; { register int r; int modf, nargs, recurf; - register struct tree *tree; + register struct node *tree; register struct table *table; /*fprintf(stderr, "rcexpr1(0x%08x, 0x%08x, 0x%08x)\n", atree, atable, reg);*/ @@ -200,12 +200,12 @@ int rcexpr1(atree, atable, reg) struct tree *atree; struct table *atable; int re again: if((tree=atree)==0) return(0); - if (tree->t_type==VOID) { + if (tree->n_type==VOID) { if (table!=efftab) error1("Illegal use of void"); - tree->t_type = INT; + tree->n_type = INT; } - if (opdope1[tree->t_op]&RELAT && ((struct tnode *)tree)->tn_tr2->t_op==CON + if (opdope1[tree->n_op]&RELAT && ((struct tnode *)tree)->tn_tr2->n_op==CON && ((struct cnode *)((struct tnode *)tree)->tn_tr2)->cn_value==0 && table==cctab) tree = atree = ((struct tnode *)tree)->tn_tr1; @@ -214,15 +214,15 @@ again: * ignore the select, otherwise * do the shift and mask. */ - if (tree->t_op == FSELT) { + if (tree->n_op == FSELT) { if (table==efftab) atree = tree = ((struct tnode *)tree)->tn_tr1; else { - tree->t_op = FSEL; + tree->n_op = FSEL; atree = tree = optim(tree); } } - switch (tree->t_op) { + switch (tree->n_op) { /* * Structure assignments @@ -283,7 +283,7 @@ again: #define ttree ((struct tnode *)tree) if (table==cctab) { ttree->tn_op = TAND; - ttree->tn_tr2 = optim((struct tree *)tnode(COMPL, ttree->tn_type, ttree->tn_tr2, TNULL)); + ttree->tn_tr2 = optim((struct node *)tnode(COMPL, ttree->tn_type, ttree->tn_tr2, (struct node *)NULL)); } break; #undef ttree @@ -322,8 +322,8 @@ again: } #endif tree = ((struct tnode *)tree)->tn_tr2; - if(tree->t_op) { - while (tree->t_op==COMMA) { + if(tree->n_op) { + while (tree->n_op==COMMA) { r += comarg(((struct tnode *)tree)->tn_tr2, &modf); tree = ((struct tnode *)tree)->tn_tr1; nargs++; @@ -334,10 +334,10 @@ again: tree = atree; #define ttree ((struct tnode *)tree) ttree->tn_op = CALL2; - if (modf && ttree->tn_tr1->t_op==NAME + if (modf && ttree->tn_tr1->n_op==NAME && ((struct nnode *)ttree->tn_tr1)->nn_class==EXTERN) ttree->tn_op = CALL1; - if (cexpr((struct tree *)ttree, regtab, reg)<0) + if (cexpr((struct node *)ttree, regtab, reg)<0) error1("compiler botch: call"); popstk(r); nstack -= nargs; @@ -355,14 +355,14 @@ again: #define ttree ((struct tnode *)tree) if (ttree->tn_type != LONG && ttree->tn_type != UNLONG) break; - if (ttree->tn_tr2->t_op==ITOL) + if (ttree->tn_tr2->n_op==ITOL) ttree->tn_tr2 = ((struct tnode *)ttree->tn_tr2)->tn_tr1; else - ttree->tn_tr2 = optim((struct tree *)tnode(LTOI,INT,ttree->tn_tr2,TNULL)); + ttree->tn_tr2 = optim((struct node *)tnode(LTOI,INT,ttree->tn_tr2,(struct node *)NULL)); if (ttree->tn_op==ASULSH) { ttree->tn_op = UASLSHL; - ttree->tn_tr1 = (struct tree *)tnode(AMPER, LONG+PTR, ttree->tn_tr1, TNULL); + ttree->tn_tr1 = (struct node *)tnode(AMPER, LONG+PTR, ttree->tn_tr1, (struct node *)NULL); } else ttree->tn_op = ULLSHIFT; @@ -373,10 +373,10 @@ again: case LSHIFT: #define ttree ((struct tnode *)tree) if (ttree->tn_type==LONG || ttree->tn_type==UNLONG) { - if (ttree->tn_tr2->t_op==ITOL) + if (ttree->tn_tr2->n_op==ITOL) ttree->tn_tr2 = ((struct tnode *)ttree->tn_tr2)->tn_tr1; else - ttree->tn_tr2 = optim((struct tree *)tnode(LTOI,INT,ttree->tn_tr2,TNULL)); + ttree->tn_tr2 = optim((struct node *)tnode(LTOI,INT,ttree->tn_tr2,(struct node *)NULL)); if (ttree->tn_op==ASLSH) ttree->tn_op = ASLSHL; else @@ -390,7 +390,7 @@ again: */ case TIMES: case ASTIMES: - tree = (struct tree *)pow2((struct tnode *)tree); + tree = (struct node *)pow2((struct tnode *)tree); } /* * Try to find postfix ++ and -- operators that can be @@ -399,7 +399,7 @@ again: /* delay() has to be able to assume input pointer is a tnode */ if (tree != atree) abort(); if (table!=cctab && table!=cregtab && recurf<2 - && (opdope1[tree->t_op]&LEAF)==0) { + && (opdope1[tree->n_op]&LEAF)==0) { if (r=delay(&atree, table, reg)) { tree = atree; table = efftab; @@ -411,50 +411,50 @@ again: * so reg = x+y is done as reg = x; reg += y */ if (recurf==0 && reorder(&atree, table, reg)) { - if (table==cctab && atree->t_op==NAME) + if (table==cctab && atree->n_op==NAME) return(reg); } tree = atree; - if (table==efftab && tree->t_op==NAME) + if (table==efftab && tree->n_op==NAME) return(reg); if ((r=cexpr(tree, table, reg))>=0) { - if (table==cregtab && (tree->t_op==INCAFT - || tree->t_op==DECAFT || tree->t_op==TIMES)) + if (table==cregtab && (tree->n_op==INCAFT + || tree->n_op==DECAFT || tree->n_op==TIMES)) goto fixup; return(r); } - if (table!=regtab && (table!=cctab||(opdope1[tree->t_op]&RELAT)==0)) { + if (table!=regtab && (table!=cctab||(opdope1[tree->n_op]&RELAT)==0)) { if((r=cexpr(tree, regtab, reg))>=0) { fixup: modf = isfloat(tree); - dbprint(tree->t_op); + dbprint(tree->n_op); if (table==sptab || table==lsptab) { - if (tree->t_type==LONG || tree->t_type==UNLONG){ - fprintf(temp_fp[temp_fi], /*printf(*/"mov\tr%d,-(sp)\n",r+1); + if (tree->n_type==LONG || tree->n_type==UNLONG){ + fprintf(temp_fp[temp_fi], "mov\tr%d,-(sp)\n",r+1); nstack++; } - fprintf(temp_fp[temp_fi], /*printf(*/"mov%s r%d,%s(sp)\n", modf=='f'?"f":"", r, + fprintf(temp_fp[temp_fi], "mov%s r%d,%s(sp)\n", modf=='f'?"f":"", r, table==sptab? "-":""); nstack++; } if (table==cctab || table==cregtab) - fprintf(temp_fp[temp_fi], /*printf(*/"tst%s r%d\n", modf=='f'?"f":"", r); + fprintf(temp_fp[temp_fi], "tst%s r%d\n", modf=='f'?"f":"", r); return(r); } } /* * Special grace for unsigned chars as right operands */ - if (opdope1[tree->t_op]&BINARY && ((struct tnode *)tree)->tn_tr2->t_type==UNCHAR) { + if (opdope1[tree->n_op]&BINARY && ((struct tnode *)tree)->tn_tr2->n_type==UNCHAR) { #define ttree ((struct tnode *)tree) - ttree->tn_tr2 = (struct tree *)tnode(LOAD, UNSIGN, ttree->tn_tr2, TNULL); - return(rcexpr1((struct tree *)ttree, table, reg)); + ttree->tn_tr2 = (struct node *)tnode(LOAD, UNSIGN, ttree->tn_tr2, (struct node *)NULL); + return(rcexpr1((struct node *)ttree, table, reg)); #undef ttree } /* * There's a last chance for this operator */ - if (tree->t_op==LTOI) { + if (tree->n_op==LTOI) { #define ttree ((struct tnode *)tree) r = rcexpr1(ttree->tn_tr1, regtab, reg); if (r >= 0) { @@ -464,12 +464,12 @@ again: #undef ttree } - r = tree->t_op; - if (tree->t_type == STRUCT) + r = tree->n_op; + if (tree->n_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, - tree->t_type); + tree->n_type); else error1("No code table for op %d", r); return(reg); @@ -484,17 +484,17 @@ again: * Most of the work is the macro-expansion of the * code table. */ -int cexpr(tree, table, areg) register struct tree *tree; struct table *table; int areg; { +int cexpr(tree, table, areg) register struct node *tree; struct table *table; int areg; { int c, r; - register struct tree *p, *p1; + register struct node *p, *p1; struct table *ctable; - struct tree *p2; + struct node *p2; char *string; int reg, reg1, rreg, flag, opd; struct optab *opt; reg = areg; - c = tree->t_op; + c = tree->n_op; opd = opdope1[c]; /* * When the value of a relational or a logical expression is @@ -502,10 +502,10 @@ int cexpr(tree, table, areg) register struct tree *tree; struct table *table; in */ if ((opd&RELAT||c==LOGAND||c==LOGOR||c==EXCLA) && table!=cctab) { cbranch1(tree, c=isn1++, 1, reg); - rcexpr1((struct tree *)&czero, table, reg); + rcexpr1((struct node *)&czero, table, reg); branch1(isn1, 0, 0); label1(c); - rcexpr1((struct tree *)&cone, table, reg); + rcexpr1((struct node *)&cone, table, reg); label1(isn1++); return(reg); } @@ -531,8 +531,8 @@ int cexpr(tree, table, areg) register struct tree *tree; struct table *table; in /* * long values take 2 registers. */ - if ((tree->t_type==LONG||tree->t_type==UNLONG||opd&RELAT&&(((struct tnode *)tree)->tn_tr1->t_type==LONG||((struct tnode *)tree)->tn_tr1->t_type==UNLONG)) - && tree->t_op!=ITOL) + if ((tree->n_type==LONG||tree->n_type==UNLONG||opd&RELAT&&(((struct tnode *)tree)->tn_tr1->n_type==LONG||((struct tnode *)tree)->tn_tr1->n_type==UNLONG)) + && tree->n_op!=ITOL) reg1++; /* * Leaves of the expression tree @@ -545,7 +545,7 @@ int cexpr(tree, table, areg) register struct tree *tree; struct table *table; in * x + (-1) is better done as x-1. */ if (ttree->tn_op==PLUS||ttree->tn_op==ASPLUS) { - if ((p1=ttree->tn_tr2)->t_op==CON && ((struct cnode *)p1)->cn_value==-1) { + if ((p1=ttree->tn_tr2)->n_op==CON && ((struct cnode *)p1)->cn_value==-1) { #define cp1 ((struct cnode *)p1) cp1->cn_value = -cp1->cn_value; ttree->tn_op += (MINUS-PLUS); @@ -556,10 +556,10 @@ int cexpr(tree, table, areg) register struct tree *tree; struct table *table; in * Because of a peculiarity of the PDP11 table * char = *intreg++ and *--intreg cannot go through. */ - if (ttree->tn_tr2 && (ttree->tn_tr2->t_op==AUTOI||ttree->tn_tr2->t_op==AUTOD) - && (ttree->tn_tr1->t_type==CHAR || ttree->tn_tr1->t_type==UNCHAR) - && ttree->tn_tr2->t_type!=CHAR && ttree->tn_tr2->t_type!=UNCHAR) - ttree->tn_tr2 = (struct tree *)tnode(LOAD, ttree->tn_tr2->t_type, ttree->tn_tr2, TNULL); + if (ttree->tn_tr2 && (ttree->tn_tr2->n_op==AUTOI||ttree->tn_tr2->n_op==AUTOD) + && (ttree->tn_tr1->n_type==CHAR || ttree->tn_tr1->n_type==UNCHAR) + && ttree->tn_tr2->n_type!=CHAR && ttree->tn_tr2->n_type!=UNCHAR) + ttree->tn_tr2 = (struct node *)tnode(LOAD, ttree->tn_tr2->n_type, ttree->tn_tr2, (struct node *)NULL); /* * Another peculiarity of the PDP11 table manifested itself when * amplifying the move3: table. The same case which optimizes @@ -574,10 +574,10 @@ int cexpr(tree, table, areg) register struct tree *tree; struct table *table; in * 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 (ttree->tn_tr2 && ttree->tn_tr1->t_op == NAME + if (ttree->tn_tr2 && ttree->tn_tr1->n_op == NAME && ((struct nnode *)ttree->tn_tr1)->nn_class == REG && ttree->tn_op == ASSIGN - && ttree->tn_tr2->t_type == UNCHAR) - ttree->tn_tr2 = (struct tree *)tnode(LOAD, UNSIGN, ttree->tn_tr2, TNULL); + && ttree->tn_tr2->n_type == UNCHAR) + ttree->tn_tr2 = (struct node *)tnode(LOAD, UNSIGN, ttree->tn_tr2, (struct node *)NULL); if (table==cregtab) table = regtab; /* @@ -599,22 +599,22 @@ int cexpr(tree, table, areg) register struct tree *tree; struct table *table; in if (table!=cctab || c==INCAFT || c==DECAFT || ttree->tn_type==LONG || ttree->tn_type==UNLONG /* || c==ASRSH || c==ASLSH || c==ASULSH || ttree->tn_tr1->tn_type==UNCHAR */ || c==ASRSH || c==ASLSH || c==ASULSH - || (opt = match((struct tree *)ttree, efftab, r, 0)) == 0) - if ((opt=match((struct tree *)ttree, table, r, 0))==0) + || (opt = match((struct node *)ttree, efftab, r, 0)) == 0) + if ((opt=match((struct node *)ttree, table, r, 0))==0) return(-1); string = opt->tabstring; p1 = ttree->tn_tr1; - if (p1->t_op==FCON && ((struct fnode *)p1)->fn_value>0) { + if (p1->n_op==FCON && ((struct fnode *)p1)->fn_value>0) { #define fp1 ((struct fnode *)p1) #ifdef pdfp11 /* nonportable */ - fprintf(temp_fp[temp_fi], /*printf(*/".data\nL%d:%o;%o;%o;%o\n.text\n", fp1->fn_value, + fprintf(temp_fp[temp_fi], ".data\nL%d:%o;%o;%o;%o\n.text\n", fp1->fn_value, ((_UNSIGNED_INT *)&(fp1->fn_fvalue))[0], ((_UNSIGNED_INT *)&(fp1->fn_fvalue))[1], ((_UNSIGNED_INT *)&(fp1->fn_fvalue))[2], ((_UNSIGNED_INT *)&(fp1->fn_fvalue))[3] ); #else - fprintf(temp_fp[temp_fi], /*printf(*/".data\nL%d:%o;%o;%o;%o\n.text\n", fp1->fn_value, + fprintf(temp_fp[temp_fi], ".data\nL%d:%o;%o;%o;%o\n.text\n", fp1->fn_value, (int)(fp1->fn_fvalue.h >> 16) & 0xffff, (int)fp1->fn_fvalue.h & 0xffff, (int)(fp1->fn_fvalue.l >> 16) & 0xffff, @@ -626,17 +626,17 @@ int cexpr(tree, table, areg) register struct tree *tree; struct table *table; in p2 = 0; if (opdope1[ttree->tn_op]&BINARY) { p2 = ttree->tn_tr2; - if (p2->t_op==FCON && ((struct fnode *)p2)->fn_value>0) { + if (p2->n_op==FCON && ((struct fnode *)p2)->fn_value>0) { #define fp2 ((struct fnode *)p2) #ifdef pdp11 /* nonportable */ - fprintf(temp_fp[temp_fi], /*printf(*/".data\nL%d:%o;%o;%o;%o\n.text\n", fp2->fn_value, + fprintf(temp_fp[temp_fi], ".data\nL%d:%o;%o;%o;%o\n.text\n", fp2->fn_value, ((_UNSIGNED_INT *)&(fp2->fn_fvalue))[0], ((_UNSIGNED_INT *)&(fp2->fn_fvalue))[1], ((_UNSIGNED_INT *)&(fp2->fn_fvalue))[2], ((_UNSIGNED_INT *)&(fp2->fn_fvalue))[3] ); #else - fprintf(temp_fp[temp_fi], /*printf(*/".data\nL%d:%o;%o;%o;%o\n.text\n", fp2->fn_value, + fprintf(temp_fp[temp_fi], ".data\nL%d:%o;%o;%o;%o\n.text\n", fp2->fn_value, (int)(fp2->fn_fvalue.h >> 16) & 0xffff, (int)fp2->fn_fvalue.h & 0xffff, (int)(fp2->fn_fvalue.l >> 16) & 0xffff, @@ -661,12 +661,12 @@ loop: break; case '\0': - if (!isfloat((struct tree *)ttree)) + if (!isfloat((struct node *)ttree)) if (ttree->tn_op==DIVIDE||ttree->tn_op==ASDIV) reg--; if (table==regtab && (opdope1[ttree->tn_op]&ASSGOP)) { - if (ttree->tn_tr1->t_type==CHAR) - fprintf(temp_fp[temp_fi], /*printf(*/"movb r%d,r%d\n", reg, reg); + if (ttree->tn_tr1->n_type==CHAR) + fprintf(temp_fp[temp_fi], "movb r%d,r%d\n", reg, reg); } return(reg); @@ -705,33 +705,33 @@ loop: /* B1 */ case 'C': if ((opd&LEAF) != 0) - p = (struct tree *)ttree; + p = (struct node *)ttree; else p = p1; goto pbyte; /* BF */ case 'P': - p = (struct tree *)ttree; + p = (struct node *)ttree; goto pb1; /* B2 */ case 'D': p = p2; pbyte: - if (p->t_type==CHAR || p->t_type==UNCHAR) - fputc('b', temp_fp[temp_fi]) /*putchar('b')*/; + if (p->n_type==CHAR || p->n_type==UNCHAR) + fputc('b', temp_fp[temp_fi]); pb1: if (isfloat(p)) - fputc('f', temp_fp[temp_fi]) /*putchar('f')*/; + fputc('f', temp_fp[temp_fi]); goto loop; /* BE */ case 'L': - 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 = (struct tree *)ttree; + if (p1->n_type==CHAR || p2->n_type==CHAR + || p1->n_type==UNCHAR || p2->n_type==UNCHAR) + fputc('b', temp_fp[temp_fi]); + p = (struct node *)ttree; goto pb1; /* F */ @@ -748,7 +748,7 @@ loop: /* H */ case 'H': - p = (struct tree *)ttree; + p = (struct node *)ttree; flag = 04; subtre: @@ -774,10 +774,10 @@ loop: ctable = cregtab; if ((c&01)!=0) { /* previous code was accessing tn_tr1 without a type check */ - if (opdope1[p->t_op] & LEAF) abort(); + if (opdope1[p->n_op] & LEAF) abort(); p = ((struct tnode *)p)->tn_tr1; if(collcon(p) && ctable!=sptab) { - if (p->t_op==STAR) + if (p->n_op==STAR) p = ((struct tnode *)p)->tn_tr1; p = ((struct tnode *)p)->tn_tr1; } @@ -787,7 +787,7 @@ loop: if (c&010) r = reg1; else - if (opdope1[p->t_op]&LEAF || ((struct tnode *)p)->tn_degree < 2) + if (opdope1[p->n_op]&LEAF || ((struct tnode *)p)->tn_degree < 2) r = reg; else r = areg; @@ -800,7 +800,7 @@ loop: else reg1 = rreg; } else if (rreg!=reg) - if ((c&020)==0 && oddreg((struct tree *)ttree, 0)==0 && ttree->tn_type!=LONG + if ((c&020)==0 && oddreg((struct node *)ttree, 0)==0 && ttree->tn_type!=LONG && ttree->tn_type!=UNLONG && (flag&04 || flag&01&&xdcalc(p2,nreg-rreg-1)<=(opt->tabdeg2&077) @@ -834,20 +834,20 @@ loop: else longjmp(jmpbuf, 1); } - fprintf(temp_fp[temp_fi], /*printf(*/"r%d", r); + fprintf(temp_fp[temp_fi], "r%d", r); goto loop; case '-': /* check -(sp) */ if (*string=='(') { nstack++; if (table!=lsptab) - fputc('-', temp_fp[temp_fi]) /*putchar('-')*/; + fputc('-', temp_fp[temp_fi]); goto loop; } break; case ')': /* check (sp)+ */ - fputc(')', temp_fp[temp_fi]) /*putchar(')')*/; + fputc(')', temp_fp[temp_fi]); if (*string=='+') nstack--; goto loop; @@ -855,28 +855,28 @@ loop: /* #1 */ case '#': /* previous code was accessing tn_tr1 without a type check */ - if (opdope1[p1->t_op] & LEAF) abort(); + if (opdope1[p1->n_op] & LEAF) abort(); p = ((struct tnode *)p1)->tn_tr1; goto nmbr; /* #2 */ case '"': /* previous code was accessing tn_tr1 without a type check */ - if (opdope1[p2->t_op] & LEAF) abort(); + if (opdope1[p2->n_op] & LEAF) abort(); p = ((struct tnode *)p2)->tn_tr1; nmbr: if(collcon(p)) { - if (p->t_op==STAR) { - fprintf(temp_fp[temp_fi], /*printf(*/"*"); + if (p->n_op==STAR) { + fprintf(temp_fp[temp_fi], "*"); p = ((struct tnode *)p)->tn_tr1; } - if ((p = ((struct tnode *)p)->tn_tr2)->t_op == CON) { + if ((p = ((struct tnode *)p)->tn_tr2)->n_op == CON) { #define cp ((struct cnode *)p) if (cp->cn_value) psoct(cp->cn_value); #undef cp - } else if (p->t_op==AMPER) + } else if (p->n_op==AMPER) pname(((struct tnode *)p)->tn_tr1, 0); } goto loop; @@ -887,12 +887,12 @@ loop: case 'T': c = reg-1; if (uns(p1) || uns(p2)) { - fprintf(temp_fp[temp_fi], /*printf(*/"clr r%d\n", c); + fprintf(temp_fp[temp_fi], "clr r%d\n", c); goto loop; } if (dcalc(p1, 5)>12 && !match(p1, cctab, 10, 0)) - fprintf(temp_fp[temp_fi], /*printf(*/"tst r%d\n", reg); - fprintf(temp_fp[temp_fi], /*printf(*/"sxt r%d\n", c); + fprintf(temp_fp[temp_fi], "tst r%d\n", reg); + fprintf(temp_fp[temp_fi], "sxt r%d\n", c); goto loop; case 'V': /* adc sbc, clr, or sxt as required for longs */ @@ -901,7 +901,7 @@ loop: case ASPLUS: case INCBEF: case INCAFT: - fprintf(temp_fp[temp_fi], /*printf(*/"adc"); + fprintf(temp_fp[temp_fi], "adc"); break; case MINUS: @@ -909,7 +909,7 @@ loop: case NEG: case DECBEF: case DECAFT: - fprintf(temp_fp[temp_fi], /*printf(*/"sbc"); + fprintf(temp_fp[temp_fi], "sbc"); break; case ASSIGN: @@ -921,11 +921,11 @@ loop: case ASULSH: p = ttree->tn_tr1; lcasev: - if (p->t_type!=LONG && p->t_type!=UNLONG) { + if (p->n_type!=LONG && p->n_type!=UNLONG) { if (uns(p) || uns(ttree->tn_tr2)) - fprintf(temp_fp[temp_fi], /*printf(*/"clr"); + fprintf(temp_fp[temp_fi], "clr"); else - fprintf(temp_fp[temp_fi], /*printf(*/"sxt"); + fprintf(temp_fp[temp_fi], "sxt"); goto loop; } default: @@ -941,7 +941,7 @@ loop: case 'Z': /* previous code was accessing fa_mask without a type check */ if (ttree->tn_op != FSELA) abort(); - fprintf(temp_fp[temp_fi], /*printf(*/"$%o", UNS(((struct fasgn *)ttree)->fa_mask)); + fprintf(temp_fp[temp_fi], "$%o", UNS(((struct fasgn *)ttree)->fa_mask)); goto loop; /* @@ -954,7 +954,7 @@ loop: return(reg); goto loop; } - fputc(c, temp_fp[temp_fi]) /*putchar(c)*/; + fputc(c, temp_fp[temp_fi]); goto loop; #undef ttree } @@ -964,12 +964,12 @@ loop: * on the subtrees and then on the tree itself. * It returns non-zero if anything changed. */ -int reorder(treep, table, reg) struct tree **treep; struct table *table; int reg; { +int reorder(treep, table, reg) struct node **treep; struct table *table; int reg; { register int r, o; - register struct tree *p; + register struct node *p; p = *treep; - o = p->t_op; + o = p->n_op; if (opdope1[o]&LEAF||o==LOGOR||o==LOGAND||o==SEQNC||o==QUEST||o==COLON) return(0); #define tp ((struct tnode *)p) @@ -997,40 +997,40 @@ int reorder(treep, table, reg) struct tree **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) struct tree **treep; struct table *table; int reg; int recurf; { - register struct tree *p, *p1; +int sreorder(treep, table, reg, recurf) struct node **treep; struct table *table; int reg; int recurf; { + register struct node *p, *p1; p = *treep; - if (opdope1[p->t_op]&LEAF) + if (opdope1[p->n_op]&LEAF) return(0); #define tp ((struct tnode *)p) if (tp->tn_op==PLUS && recurf) if (reorder(&tp->tn_tr2, table, reg)) /* in this case optim() is guaranteed to return a struct tnode */ { - *treep = p = optim((struct tree *)tp); - if (opdope1[p->t_op] & LEAF) abort(); + *treep = p = optim((struct node *)tp); + if (opdope1[p->n_op] & LEAF) abort(); } - if ((p1 = tp->tn_tr1)==TNULL) + if ((p1 = tp->tn_tr1)==(struct node *)NULL) return(0); if (tp->tn_op==STAR || tp->tn_op==PLUS) { if (recurf && reorder(&tp->tn_tr1, table, reg)) { /* in this case optim() might not return a struct tnode */ - *treep = p = optim((struct tree *)tp); - if (opdope1[p->t_op]&LEAF) + *treep = p = optim((struct node *)tp); + if (opdope1[p->n_op]&LEAF) return(0); /* but it's a struct tnode, so continue accessing via tp */ } p1 = tp->tn_tr1; } - if (p1->t_op==NAME) switch(tp->tn_op) { + if (p1->n_op==NAME) switch(tp->tn_op) { case ASLSH: case ASRSH: case ASSIGN: if (((struct nnode *)p1)->nn_class != REG || ((struct nnode *)p1)->nn_type==CHAR || isfloat(tp->tn_tr2)) return(0); - if (tp->tn_op==ASSIGN) switch (tp->tn_tr2->t_op) { + if (tp->tn_op==ASSIGN) switch (tp->tn_tr2->n_op) { case RSHIFT: if (tp->tn_type==UNSIGN) return(0); @@ -1038,7 +1038,7 @@ int sreorder(treep, table, reg, recurf) struct tree **treep; struct table *table case TIMES: if (!ispow2((struct tnode *)tp->tn_tr2)) break; - tp->tn_tr2 = (struct tree *)pow2((struct tnode *)tp->tn_tr2); + tp->tn_tr2 = (struct node *)pow2((struct tnode *)tp->tn_tr2); case PLUS: case MINUS: case AND: @@ -1048,21 +1048,24 @@ int sreorder(treep, table, reg, recurf) struct tree **treep; struct table *table case LSHIFT: caseGEN: p1 = ((struct tnode *)tp->tn_tr2)->tn_tr2; + /* here tp->tn_tr1 (former p1) is a locnnode of class REG, checked above */ + /* XXX formerly nn_class was not checked in the below, so random values of */ + /* nloc/name could (rarely) have caused the optimization not to be applied */ if (xdcalc(p1, 16) > 12 - || p1->t_op==NAME - &&(((struct nnode *)p1)->nn_nloc==((struct nnode *)tp->tn_tr1)->nn_nloc - || ((struct nnode *)p1)->nn_regno==((struct nnode *)tp->tn_tr1)->nn_nloc)) + || p1->n_op==NAME + &&(((struct nnode *)p1)->nn_class == REG && ((struct locnnode *)p1)->locnn_nloc==((struct locnnode *)tp->tn_tr1)->locnn_nloc + || (((struct nnode *)p1)->nn_class == OFFS || ((struct nnode *)p1)->nn_class == SOFFS || ((struct nnode *)p1)->nn_class == XOFFS) && ((struct nnode *)p1)->nn_regno==((struct locnnode *)tp->tn_tr1)->locnn_nloc)) return(0); p1 = tp->tn_tr2; #define tp1 ((struct tnode *)p1) tp->tn_tr2 = tp1->tn_tr1; - if (tp1->tn_tr1->t_op!=NAME + if (tp1->tn_tr1->n_op!=NAME || ((struct nnode *)tp1->tn_tr1)->nn_class!=REG - || ((struct nnode *)tp1->tn_tr1)->nn_nloc!=((struct nnode *)tp->tn_tr1)->nn_nloc) - rcexpr1((struct tree *)tp, efftab, reg); + || ((struct locnnode *)tp1->tn_tr1)->locnn_nloc!=((struct locnnode *)tp->tn_tr1)->locnn_nloc) + rcexpr1((struct node *)tp, efftab, reg); tp->tn_tr2 = tp1->tn_tr2; tp->tn_op = tp1->tn_op + ASPLUS - PLUS; - *treep = (struct tree *)tp; + *treep = (struct node *)tp; return(1); #undef tp1 } @@ -1082,7 +1085,7 @@ int sreorder(treep, table, reg, recurf) struct tree **treep; struct table *table OK: if (table==cctab||table==cregtab) reg += 020; - rcexpr1(optim((struct tree *)tp), efftab, ~reg); + rcexpr1(optim((struct node *)tp), efftab, ~reg); *treep = p1; return(1); } @@ -1101,17 +1104,17 @@ int sreorder(treep, table, reg, recurf) struct tree **treep; struct table *table * Otherwise it uses sdelay to search for inc/dec * among the operands. */ -int delay(treep, table, reg) struct tree **treep; struct table *table; int reg; { +int delay(treep, table, reg) struct node **treep; struct table *table; int reg; { register struct tnode *p; - register struct tree *p1; + register struct node *p1; register int r; p = (struct tnode *)*treep; if ((p->tn_op==INCAFT||p->tn_op==DECAFT) - && p->tn_tr1->t_op==NAME) { + && p->tn_tr1->n_op==NAME) { r = ((struct nnode *)p->tn_tr1)->nn_class; if (r == EXTERN || r == OFFS || r == STATIC && - p->tn_tr1->t_type == UNCHAR) + p->tn_tr1->n_type == UNCHAR) return(1+rcexpr1(p->tn_tr1, table, reg)); else return(1+rcexpr1(paint(p->tn_tr1, p->tn_type), table,reg)); @@ -1137,28 +1140,28 @@ int delay(treep, table, reg) struct tree **treep; struct table *table; int reg; if (p1==0) p1 = sdelay(&p->tn_tr1); if (p1) { - r = rcexpr1(optim((struct tree *)p), table, reg); + r = rcexpr1(optim((struct node *)p), table, reg); *treep = p1; return(r+1); } return(0); } -struct tree *sdelay(ap) struct tree **ap; { - register struct tree *p, *p1; +struct node *sdelay(ap) struct node **ap; { + register struct node *p, *p1; - if ((p = *ap)==TNULL) - return(TNULL); - if ((p->t_op==INCAFT||p->t_op==DECAFT) && ((struct tnode *)p)->tn_tr1->t_op==NAME) { + if ((p = *ap)==(struct node *)NULL) + return((struct node *)NULL); + if ((p->n_op==INCAFT||p->n_op==DECAFT) && ((struct tnode *)p)->tn_tr1->n_op==NAME) { #define tp ((struct tnode *)p) - *ap = paint((struct tree *)ncopy((struct nnode *)tp->tn_tr1), tp->tn_type); - return((struct tree *)tp); + *ap = paint((struct node *)ncopy((struct nnode *)tp->tn_tr1), tp->tn_type); + return((struct node *)tp); #undef tp } - if (p->t_op==STAR || p->t_op==PLUS) + if (p->n_op==STAR || p->n_op==PLUS) if (p1=sdelay(&((struct tnode *)p)->tn_tr1)) return(p1); - if (p->t_op==PLUS) + if (p->n_op==PLUS) return(sdelay(&((struct tnode *)p)->tn_tr2)); return(0); } @@ -1166,27 +1169,27 @@ struct tree *sdelay(ap) struct tree **ap; { /* * Propagate possible implicit type-changing operation */ -struct tree *paint(tp, type) register struct tree *tp; register int type; { +struct node *paint(tp, type) register struct node *tp; register int type; { - if (tp->t_type==type) + if (tp->n_type==type) return(tp); - if (tp->t_type==CHAR && type==INT) + if (tp->n_type==CHAR && type==INT) return(tp); - if (tp->t_type==CHAR || tp->t_type==UNCHAR) - return(optim((struct tree *)tnode(LOAD, type, tp, TNULL))); - tp->t_type = type; - if (tp->t_op==AMPER && type&XTYPE) + if (tp->n_type==CHAR || tp->n_type==UNCHAR) + return(optim((struct node *)tnode(LOAD, type, tp, (struct node *)NULL))); + tp->n_type = type; + if (tp->n_op==AMPER && type&XTYPE) #define ttp ((struct tnode *)tp) ttp->tn_tr1 = paint(ttp->tn_tr1, decref1(type)); #undef ttp - else if (tp->t_op==STAR) + else if (tp->n_op==STAR) #define ttp ((struct tnode *)tp) ttp->tn_tr1 = paint(ttp->tn_tr1, incref1(type)); #undef ttp - else if (tp->t_op==ASSIGN) { + else if (tp->n_op==ASSIGN) { #define ttp ((struct tnode *)tp) /* previous code was not saving back return value from paint() ??? */ - struct tree *temp = + struct node *temp = paint(ttp->tn_tr1, type); if (temp != ttp->tn_tr1) abort(); temp = @@ -1208,16 +1211,20 @@ struct nnode *ncopy(p) register struct nnode *p; { struct nnode *q; if (p->nn_class==EXTERN || p->nn_class==XOFFS) { -#define xp ((struct xnode *)p) -#define xq (*(struct xnode **)&q) - xq = (struct xnode *)getblk(sizeof(struct xnode)); - xq->xn_name = xp->xn_name; -#undef xp -#undef xq +#define extp ((struct extnnode *)p) +#define extq (*(struct extnnode **)&q) + extq = (struct extnnode *)getblk(sizeof(struct extnnode)); + extq->extnn_name = extp->extnn_name; +#undef extp +#undef extq } else { - q = (struct nnode *)getblk(sizeof(struct nnode)); - q->nn_nloc = p->nn_nloc; +#define locp ((struct locnnode *)p) +#define locq (*(struct locnnode **)&q) + locq = (struct locnnode *)getblk(sizeof(struct locnnode)); + locq->locnn_nloc = locp->locnn_nloc; +#undef locp +#undef locq } q->nn_op = p->nn_op; q->nn_type = p->nn_type; @@ -1231,10 +1238,10 @@ struct nnode *ncopy(p) register struct nnode *p; { * If the tree can be immediately loaded into a register, * produce code to do so and return success. */ -int chkleaf(tree, table, reg) register struct tree *tree; struct table *table; int reg; { +int chkleaf(tree, table, reg) register struct node *tree; struct table *table; int reg; { struct tnode lbuf; - if (tree->t_op!=STAR && dcalc(tree, nreg-reg) > 12) + if (tree->n_op!=STAR && dcalc(tree, nreg-reg) > 12) return(-1); /* if dcalc() returns 0 then either tree == NULL or tree is a struct tnode */ #define ttree ((struct tnode *)tree) @@ -1243,8 +1250,8 @@ int chkleaf(tree, table, reg) register struct tree *tree; struct table *table; i lbuf.tn_degree = ttree->tn_degree; lbuf.tn_tr1 = tree; /* can't have garbage in lbuf.tr2, cexpr() will deref it if non-NULL */ - lbuf.tn_tr2 = TNULL; - return(rcexpr1((struct tree *)&lbuf, table, reg)); + lbuf.tn_tr2 = (struct node *)NULL; + return(rcexpr1((struct node *)&lbuf, table, reg)); } /* @@ -1254,15 +1261,15 @@ int chkleaf(tree, table, reg) register struct tree *tree; struct table *table; i * Return the number of bytes pushed, * for future popping. */ -int comarg(tree, flagp) register struct tree *tree; int *flagp; { +int comarg(tree, flagp) register struct node *tree; int *flagp; { register int retval; int i; int size; - if (/*tree->t_op==STRASG*/tree->t_type==STRUCT) { + if (/*tree->n_op==STRASG*/tree->n_type==STRUCT) { /* size = tree->fa_mask; tree = tree->tn_tr1;*/ - size = tree->t_strp->S.ssize; + size = tree->n_strp->S.ssize; tree = strfunc(tree); if (size <= sizeof(_INT)) { paint(tree, INT); @@ -1272,32 +1279,32 @@ int comarg(tree, flagp) register struct tree *tree; int *flagp; { paint(tree, LONG); goto normal; } - if (tree->t_op!=NAME && tree->t_op!=STAR) { + if (tree->n_op!=NAME && tree->n_op!=STAR) { error1("Unimplemented structure assignment"); return(0); } - tree = (struct tree *)tnode(AMPER, STRUCT+PTR, tree, TNULL); - tree = (struct tree *)tnode(PLUS, STRUCT+PTR, tree, (struct tree *)tconst(size, INT)); + tree = (struct node *)tnode(AMPER, STRUCT+PTR, tree, (struct node *)NULL); + tree = (struct node *)tnode(PLUS, STRUCT+PTR, tree, (struct node *)tconst(size, INT)); tree = optim(tree); retval = rcexpr1(tree, regtab, 0); size >>= 1; if (size <= 5) { for (i=0; it_type==LONG || tree->t_type==UNLONG) { + if (nstack || isfloat(tree) || tree->n_type==LONG || tree->n_type==UNLONG) { rcexpr1(tree, sptab, 0); - retval = arlength(tree->t_type); + retval = arlength(tree->n_type); } else { (*flagp)++; rcexpr1(tree, lsptab, 0); @@ -1306,24 +1313,24 @@ normal: return(retval); } -struct tree *strfunc(tp) register struct tree *tp; { - if (tp->t_op != CALL) +struct node *strfunc(tp) register struct node *tp; { + if (tp->n_op != CALL) return(tp); paint(tp, STRUCT+PTR); - return((struct tree *)tnode(STAR, STRUCT, tp, TNULL)); + return((struct node *)tnode(STAR, STRUCT, tp, (struct node *)NULL)); } /* * Compile an initializing expression */ -void doinit(type, tree) register int type; register struct tree *tree; { +void doinit(type, tree) register int type; register struct node *tree; { _FLOAT sfval; _DOUBLE fval; _LONG lval; if (type==CHAR || type==UNCHAR) { - fprintf(temp_fp[temp_fi], /*printf(*/".byte "); - if (tree->t_type&XTYPE) + fprintf(temp_fp[temp_fi], ".byte "); + if (tree->n_type&XTYPE) goto illinit; type = INT; } @@ -1332,8 +1339,8 @@ void doinit(type, tree) register int type; register struct tree *tree; { switch (type) { case INT: case UNSIGN: - if (tree->t_op==FTOI) { - if (((struct tnode *)tree)->tn_tr1->t_op!=FCON && ((struct tnode *)tree)->tn_tr1->t_op!=SFCON) + if (tree->n_op==FTOI) { + if (((struct tnode *)tree)->tn_tr1->n_op!=FCON && ((struct tnode *)tree)->tn_tr1->n_op!=SFCON) goto illinit; tree = ((struct tnode *)tree)->tn_tr1; fval = ((struct fnode *)tree)->fn_fvalue; @@ -1343,17 +1350,17 @@ void doinit(type, tree) register int type; register struct tree *tree; { #else ((struct cnode *)tree)->cn_value = fp_double_to_int(fval); #endif - } else if (tree->t_op==LTOI) { - if (((struct tnode *)tree)->tn_tr1->t_op!=LCON) + } else if (tree->n_op==LTOI) { + if (((struct tnode *)tree)->tn_tr1->n_op!=LCON) goto illinit; tree = ((struct tnode *)tree)->tn_tr1; lval = ((struct lnode *)tree)->ln_lvalue; ((struct cnode *)tree)->cn_op = CON; ((struct cnode *)tree)->cn_value = lval; } - if (tree->t_op == CON) - fprintf(temp_fp[temp_fi], /*printf(*/"%o\n", UNS(((struct cnode *)tree)->cn_value)); - else if (tree->t_op==AMPER) { + if (tree->n_op == CON) + fprintf(temp_fp[temp_fi], "%o\n", UNS(((struct cnode *)tree)->cn_value)); + else if (tree->n_op==AMPER) { pname(((struct tnode *)tree)->tn_tr1, 0); fputc('\n', temp_fp[temp_fi]) /*putchar('\n')*/; } else @@ -1362,9 +1369,9 @@ void doinit(type, tree) register int type; register struct tree *tree; { case DOUBLE: case FLOAT: - if (tree->t_op==ITOF) { + if (tree->n_op==ITOF) { #define ttree ((struct tnode *)tree) - if (ttree->tn_tr1->t_op==CON) { + if (ttree->tn_tr1->n_op==CON) { /* note: this should be changed to respect the signedness of the int */ #ifdef pdp11 fval = ((struct cnode *)ttree->tn_tr1)->cn_value; @@ -1374,11 +1381,11 @@ void doinit(type, tree) register int type; register struct tree *tree; { } else goto illinit; #undef ttree - } else if (tree->t_op==FCON || tree->t_op==SFCON) { + } else if (tree->n_op==FCON || tree->n_op==SFCON) { fval = ((struct fnode *)tree)->fn_fvalue; - } else if (tree->t_op==LTOF) { + } else if (tree->n_op==LTOF) { #define ttree ((struct tnode *)tree) - if (ttree->tn_tr1->t_op!=LCON) + if (ttree->tn_tr1->n_op!=LCON) goto illinit; /* note: this should be changed to respect the signedness of the long */ #ifdef pdp11 @@ -1393,25 +1400,25 @@ void doinit(type, tree) register int type; register struct tree *tree; { #ifdef pdp11 sfval = fval; /*nonportable*/ - fprintf(temp_fp[temp_fi], /*printf(*/"%o; %o\n", + fprintf(temp_fp[temp_fi], "%o; %o\n", ((_UNSIGNED_INT *)&sfval)[0], ((_UNSIGNED_INT *)&sfval)[1]); #else sfval = fp_double_to_float(fval); - fprintf(temp_fp[temp_fi], /*printf(*/"%o; %o\n", + fprintf(temp_fp[temp_fi], "%o; %o\n", (int)(sfval.h >> 16) & 0xffff, (int)sfval.h & 0xffff); #endif } else { #ifdef pdp11 /* nonportable */ - fprintf(temp_fp[temp_fi], /*printf(*/"%o; %o; %o; %o\n", + fprintf(temp_fp[temp_fi], "%o; %o; %o; %o\n", ((_UNSIGNED_INT *)&fval)[0], ((_UNSIGNED_INT *)&fval)[1], ((_UNSIGNED_INT *)&fval)[2], ((_UNSIGNED_INT *)&fval)[3]); #else - fprintf(temp_fp[temp_fi], /*printf(*/"%o; %o; %o; %o\n", + fprintf(temp_fp[temp_fi], "%o; %o; %o; %o\n", (int)(fval.h >> 16) & 0xffff, (int)fval.h & 0xffff, (int)(fval.l >> 16) & 0xffff, @@ -1422,55 +1429,55 @@ void doinit(type, tree) register int type; register struct tree *tree; { case UNLONG: case LONG: - if (tree->t_op==FTOL) { + if (tree->n_op==FTOL) { tree = ((struct tnode *)tree)->tn_tr1; - if (tree->t_op==SFCON) - tree->t_op = FCON; - if (tree->t_op!= FCON) + if (tree->n_op==SFCON) + tree->n_op = FCON; + if (tree->n_op!= FCON) goto illinit; #ifdef pdp11 lval = ((struct fnode *)tree)->fn_fvalue; #else lval = fp_double_to_long(((struct fnode *)tree)->fn_fvalue); #endif - } else if (tree->t_op==ITOL) { + } else if (tree->n_op==ITOL) { #define ttree ((struct tnode *)tree) - if (ttree->tn_tr1->t_op != CON) + if (ttree->tn_tr1->n_op != CON) goto illinit; if (uns(ttree->tn_tr1)) lval = (_UNSIGNED_INT)((struct cnode *)ttree->tn_tr1)->cn_value; else lval = ((struct cnode *)ttree->tn_tr1)->cn_value; #undef ttree - } else if (tree->t_op==LCON) { + } else if (tree->n_op==LCON) { lval = ((struct lnode *)tree)->ln_lvalue; } else goto illinit; /* nonportable */ - fprintf(temp_fp[temp_fi], /*printf(*/"%o; %o\n", UNS((lval>>16)), UNS(lval)); + fprintf(temp_fp[temp_fi], "%o; %o\n", UNS((lval>>16)), UNS(lval)); return; } illinit: error1("Illegal initialization"); } -void movreg(r0, r1, tree) int r0; int r1; struct tree *tree; { +void movreg(r0, r1, tree) int r0; int r1; struct node *tree; { register char *s; char c; if (r0==r1) return; - if (tree->t_type==LONG || tree->t_type == UNLONG) { + if (tree->n_type==LONG || tree->n_type == UNLONG) { if (r0>=nreg || r1>=nreg) { error1("register overflow: compiler error"); } s = "mov r%d,r%d\nmov r%d,r%d\n"; if (r0 < r1) - fprintf(temp_fp[temp_fi], /*printf(*/s, r0+1,r1+1,r0,r1); + fprintf(temp_fp[temp_fi], s, r0+1,r1+1,r0,r1); else - fprintf(temp_fp[temp_fi], /*printf(*/s, r0,r1,r0+1,r1+1); + fprintf(temp_fp[temp_fi], s, r0,r1,r0+1,r1+1); return; } c = isfloat(tree); - fprintf(temp_fp[temp_fi], /*printf(*/"mov%.1s r%d,r%d\n", &c, r0, r1); + fprintf(temp_fp[temp_fi], "mov%.1s r%d,r%d\n", &c, r0, r1); } diff --git a/c11.c b/c11.c index e1a9e9d..ea0d5e8 100644 --- a/c11.c +++ b/c11.c @@ -18,39 +18,39 @@ /*static void outname __P((char *s));*/ static void outname __P((char *buf, char *str)); -int degree(t) register struct tree *t; { - register struct tree *t1; +int degree(t) register struct node *t; { + register struct node *t1; - if (t==NULL || t->t_op==0) + if (t==NULL || t->n_op==0) return(0); - if (t->t_op == CON) + if (t->n_op == CON) return(-3); - if (t->t_op == AMPER) + if (t->n_op == AMPER) return(-2); - if (t->t_op==ITOL) { + if (t->n_op==ITOL) { /* assume isconstant() does not return an SFCON since it's ITOL not FTOL */ - if ((t1 = isconstant(t)) && (((struct cnode *)t1)->cn_value>=0 || uns(t1))) + if ((t1 = (struct node *)isconstant(t)) && (((struct cnode *)t1)->cn_value>=0 || uns(t1))) return(-2); - if (uns(t1 = ((struct tnode *)t)->tn_tr1) && opdope1[t1->t_op]&LEAF) + if (uns(t1 = ((struct tnode *)t)->tn_tr1) && opdope1[t1->n_op]&LEAF) return(-1); } - if ((opdope1[t->t_op] & LEAF) != 0) { - if (t->t_type==CHAR || t->t_type==UNCHAR || t->t_type==FLOAT) + if ((opdope1[t->n_op] & LEAF) != 0) { + if (t->n_type==CHAR || t->n_type==UNCHAR || t->n_type==FLOAT) return(1); return(0); } return(((struct tnode *)t)->tn_degree); } -void pname(p, flag) register struct tree *p; int flag; { +void pname(p, flag) register struct node *p; int flag; { register int i; loop: - switch(p->t_op) { + switch(p->n_op) { case LCON: #define lp ((struct lnode *)p) - fprintf(temp_fp[temp_fi], /*printf(*/"$%o", flag<=10? UNS(lp->ln_lvalue>>16): + fprintf(temp_fp[temp_fi], "$%o", flag<=10? UNS(lp->ln_lvalue>>16): UNS(lp->ln_lvalue)); return; #undef lp @@ -58,14 +58,14 @@ loop: case SFCON: case CON: #define cp ((struct cnode *)p) - fprintf(temp_fp[temp_fi], /*printf(*/"$"); + fprintf(temp_fp[temp_fi], "$"); psoct(cp->cn_value); return; #undef cp case FCON: #define fp ((struct fnode *)p) - fprintf(temp_fp[temp_fi], /*printf(*/"L%d", (fp->fn_value>0? fp->fn_value: -fp->fn_value)); + fprintf(temp_fp[temp_fi], "L%d", (fp->fn_value>0? fp->fn_value: -fp->fn_value)); return; #undef fp @@ -77,77 +77,92 @@ loop: if (i) { psoct(i); if (np->nn_class!=OFFS) - fputc('+', temp_fp[temp_fi]) /*putchar('+')*/; + fputc('+', temp_fp[temp_fi]); if (np->nn_class==REG) error1("Illegal use of register"); } switch(np->nn_class) { case SOFFS: +#define locnp ((struct locnnode *)np) + fprintf(temp_fp[temp_fi], "L%d(r%d)", locnp->locnn_nloc, locnp->locnn_regno); + break; +#undef locnp + case XOFFS: - pbase(np); +#define extnp ((struct extnnode *)np) + fprintf(temp_fp[temp_fi], "%s(r%d)", extnp->extnn_name, extnp->extnn_regno); + break; +#undef extnp case OFFS: - fprintf(temp_fp[temp_fi], /*printf(*/"(r%d)", np->nn_regno); - return; + /* considered to be a locnnode even though locnn_nloc is wasted space */ +#define locnp ((struct locnnode *)np) + fprintf(temp_fp[temp_fi], "(r%d)", locnp->locnn_regno); + break; +#undef locnp case EXTERN: +#define extnp ((struct extnnode *)np) + fprintf(temp_fp[temp_fi], "%s", extnp->extnn_name); + break; +#undef extnp + case STATIC: - pbase(np); - return; +#define locnp ((struct locnnode *)np) + fprintf(temp_fp[temp_fi], "L%d", locnp->locnn_nloc); + break; +#undef locnp case REG: - fprintf(temp_fp[temp_fi], /*printf(*/"r%d", np->nn_nloc); - return; +#define locnp ((struct locnnode *)np) + fprintf(temp_fp[temp_fi], "r%d", locnp->locnn_nloc); + break; +#undef locnp + + default: + error1("Compiler error: pname"); + break; } - error1("Compiler error: pname"); return; #undef np case AMPER: - fputc('$', temp_fp[temp_fi]) /*putchar('$')*/; + fputc('$', temp_fp[temp_fi]); p = ((struct tnode *)p)->tn_tr1; - if (p->t_op==NAME && ((struct nnode *)p)->nn_class==REG) + if (p->n_op==NAME && ((struct nnode *)p)->nn_class==REG) error1("Illegal use of register"); goto loop; case AUTOI: -#define np ((struct nnode *)p) - fprintf(temp_fp[temp_fi], /*printf(*/"(r%d)%s", np->nn_nloc, flag==1?"":"+"); +#define locnp ((struct locnnode *)p) + fprintf(temp_fp[temp_fi], "(r%d)%s", locnp->locnn_nloc, flag==1?"":"+"); return; -#undef np +#undef locnp case AUTOD: -#define np ((struct nnode *)p) - fprintf(temp_fp[temp_fi], /*printf(*/"%s(r%d)", flag==2?"":"-", np->nn_nloc); +#define locnp ((struct locnnode *)p) + fprintf(temp_fp[temp_fi], "%s(r%d)", flag==2?"":"-", locnp->locnn_nloc); return; -#undef np +#undef locnp case STAR: p = ((struct tnode *)p)->tn_tr1; - fputc('*', temp_fp[temp_fi]) /*putchar('*')*/; + fputc('*', temp_fp[temp_fi]); goto loop; } error1("compiler error: bad pname"); } -void pbase(p) register struct nnode *p; { - - if (p->nn_class==SOFFS || p->nn_class==STATIC) - fprintf(temp_fp[temp_fi], /*printf(*/"L%d", p->nn_nloc); - else - fprintf(temp_fp[temp_fi], /*printf(*/"%s", ((struct xnode *)p)->xn_name); -} - -int xdcalc(p, nrleft) register struct tree *p; int nrleft; { +int xdcalc(p, nrleft) register struct node *p; int nrleft; { register int d; if (p==NULL) return(0); d = dcalc(p, nrleft); - if (d<20 && (p->t_type==CHAR || p->t_type==UNCHAR)) { + if (d<20 && (p->n_type==CHAR || p->n_type==UNCHAR)) { if (nrleft>=1) d = 20; else @@ -157,12 +172,12 @@ int xdcalc(p, nrleft) register struct tree *p; int nrleft; { } /* if dcalc() returns 0 then either p == NULL or p is a struct tnode */ -int dcalc(p, nrleft) register struct tree *p; int nrleft; { - register struct tree *p1; +int dcalc(p, nrleft) register struct node *p; int nrleft; { + register struct node *p1; if (p==NULL) return(0); - switch (p->t_op) { + switch (p->n_op) { case NAME: #define np ((struct nnode *)p) @@ -192,14 +207,14 @@ int dcalc(p, nrleft) register struct tree *p; int nrleft; { case STAR: #define tp ((struct tnode *)p) p1 = tp->tn_tr1; - if (p1->t_op==NAME||p1->t_op==CON||p1->t_op==AUTOI||p1->t_op==AUTOD) + if (p1->n_op==NAME||p1->n_op==CON||p1->n_op==AUTOI||p1->n_op==AUTOD) if (tp->tn_type!=LONG && tp->tn_type!=UNLONG) return(12); break; #undef tp } /* above should have eliminated all of the leaf cases */ - if (opdope1[p->t_op] & LEAF) abort(); + if (opdope1[p->n_op] & LEAF) abort(); #define tp ((struct tnode *)p) if (tp->tn_type==LONG || tp->tn_type==UNLONG) nrleft--; @@ -207,10 +222,10 @@ int dcalc(p, nrleft) register struct tree *p; int nrleft; { #undef tp } -int notcompat(p, ast, deg, op) register struct tree *p; int ast; int deg; int op; { +int notcompat(p, ast, deg, op) register struct node *p; int ast; int deg; int op; { unsigned register at, st; - at = p->t_type; + at = p->n_type; /* * an e or n UNCHAR is to be considered an UNSIGNED, * as long as it is not pointed to. @@ -231,7 +246,7 @@ int notcompat(p, ast, deg, op) register struct tree *p; int ast; int deg; int op at = at&TYPE | 020; if (st==FLOAT && at==DOUBLE) at = FLOAT; - if (p->t_op==NAME && ((struct nnode *)p)->nn_class==REG && op==ASSIGN && st==CHAR) + if (p->n_op==NAME && ((struct nnode *)p)->nn_class==REG && op==ASSIGN && st==CHAR) return(0); return(st != at); } @@ -248,11 +263,11 @@ int prins(op, c, itable, lbl) int op; int c; struct instab *itable; int lbl; { if (!ip) break; if (ip != jmijne) { - fprintf(temp_fp[temp_fi], /*printf(*/ip, lbl); + fprintf(temp_fp[temp_fi], ip, lbl); } else { skip = isn1++; - fprintf(temp_fp[temp_fi], /*printf(*/ip, skip); + fprintf(temp_fp[temp_fi], ip, skip); } return(skip); } @@ -261,46 +276,46 @@ int prins(op, c, itable, lbl) int op; int c; struct instab *itable; int lbl; { return(skip); } -int collcon(p) register struct tree *p; { +int collcon(p) register struct node *p; { register int op; if (p==NULL) return(0); - if (p->t_op==STAR) { - if (p->t_type==LONG+PTR || p->t_type==UNLONG+PTR) /* avoid *x(r); *x+2(r) */ + if (p->n_op==STAR) { + if (p->n_type==LONG+PTR || p->n_type==UNLONG+PTR) /* avoid *x(r); *x+2(r) */ return(0); p = ((struct tnode *)p)->tn_tr1; } - if (p->t_op==PLUS) { - op = ((struct tnode *)p)->tn_tr2->t_op; + if (p->n_op==PLUS) { + op = ((struct tnode *)p)->tn_tr2->n_op; if (op==CON || op==AMPER) return(1); } return(0); } -int isfloat(t) register struct tree *t; { +int isfloat(t) register struct node *t; { - if ((opdope1[t->t_op]&RELAT)!=0) + if ((opdope1[t->n_op]&RELAT)!=0) t = ((struct tnode *)t)->tn_tr1; - if (t->t_type==FLOAT || t->t_type==DOUBLE) { + if (t->n_type==FLOAT || t->n_type==DOUBLE) { nfloat = 1; return('f'); } return(0); } -int oddreg(t, reg) register struct tree *t; register int reg; { +int oddreg(t, reg) register struct node *t; register int reg; { if (!isfloat(t)) { - if (opdope1[t->t_op]&RELAT) { + if (opdope1[t->n_op]&RELAT) { #define tt ((struct tnode *)t) - if (tt->tn_tr1->t_type==LONG || tt->tn_tr1->t_type==UNLONG) + if (tt->tn_tr1->n_type==LONG || tt->tn_tr1->n_type==UNLONG) return((reg+1) & ~01); return(reg); #undef tt } - switch(t->t_op) { + switch(t->n_op) { case ULLSHIFT: case UASLSHL: case LLSHIFT: @@ -389,7 +404,7 @@ void pswitch1(afp, alp, deflab) struct swtab *afp; struct swtab *alp; int deflab fp = afp; lp = alp; if (fp==lp) { - fprintf(temp_fp[temp_fi], /*printf(*/"jbr L%d\n", deflab); + fprintf(temp_fp[temp_fi], "jbr L%d\n", deflab); return; } isn1++; @@ -401,26 +416,26 @@ void pswitch1(afp, alp, deflab) struct swtab *afp; struct swtab *alp; int deflab /* direct switch */ if (range>0 && range <= 3*ncase) { if (fp->swval) - fprintf(temp_fp[temp_fi], /*printf(*/"sub $%o,r0\n", UNS(fp->swval)); - fprintf(temp_fp[temp_fi], /*printf(*/dirsw, UNS(range), deflab, isn1, isn1); + fprintf(temp_fp[temp_fi], "sub $%o,r0\n", UNS(fp->swval)); + fprintf(temp_fp[temp_fi], dirsw, UNS(range), deflab, isn1, isn1); isn1++; for (i=fp->swval; ; i++) { if (i==fp->swval) { - fprintf(temp_fp[temp_fi], /*printf(*/"L%d\n", fp->swlab); + fprintf(temp_fp[temp_fi], "L%d\n", fp->swlab); if (fp==lp) break; fp++; } else - fprintf(temp_fp[temp_fi], /*printf(*/"L%d\n", deflab); + fprintf(temp_fp[temp_fi], "L%d\n", deflab); } - fprintf(temp_fp[temp_fi], /*printf(*/".text\n"); + fprintf(temp_fp[temp_fi], ".text\n"); return; } /* simple switch */ if (ncase<10) { for (fp = afp; fp<=lp; fp++) breq(fp->swval, fp->swlab); - fprintf(temp_fp[temp_fi], /*printf(*/"jbr L%d\n", deflab); + fprintf(temp_fp[temp_fi], "jbr L%d\n", deflab); return; } /* hash switch */ @@ -442,13 +457,13 @@ void pswitch1(afp, alp, deflab) struct swtab *afp; struct swtab *alp; int deflab } } i = isn1++; - fprintf(temp_fp[temp_fi], /*printf(*/hashsw, UNS(tabs), i, i); + fprintf(temp_fp[temp_fi], hashsw, UNS(tabs), i, i); isn1++; for (i=0; iswval, tabs) */ if ((_UNSIGNED_INT)swp->swval%tabs == i) { @@ -456,16 +471,16 @@ void pswitch1(afp, alp, deflab) struct swtab *afp; struct swtab *alp; int deflab breq((int)((_UNSIGNED_INT)swp->swval/tabs), swp->swlab); } } - fprintf(temp_fp[temp_fi], /*printf(*/"jbr L%d\n", deflab); + fprintf(temp_fp[temp_fi], "jbr L%d\n", deflab); } } void breq(v, l) int v; int l; { if (v==0) - fprintf(temp_fp[temp_fi], /*printf(*/"tst r0\n"); + fprintf(temp_fp[temp_fi], "tst r0\n"); else - fprintf(temp_fp[temp_fi], /*printf(*/"cmp r0,$%o\n", UNS(v)); - fprintf(temp_fp[temp_fi], /*printf(*/"jeq L%d\n", l); + fprintf(temp_fp[temp_fi], "cmp r0,$%o\n", UNS(v)); + fprintf(temp_fp[temp_fi], "jeq L%d\n", l); } int sort(afp, alp) struct swtab *afp; struct swtab *alp; { @@ -500,7 +515,7 @@ int sort(afp, alp) struct swtab *afp; struct swtab *alp; { int ispow2(tree) register struct tnode *tree; { register int d; - if (!isfloat((struct tree *)tree) && tree->tn_tr2->t_op==CON) { + if (!isfloat((struct node *)tree) && tree->tn_tr2->n_op==CON) { d = ((struct cnode *)tree->tn_tr2)->cn_value; if (d>1 && (d&(d-1))==0) return(d); @@ -525,12 +540,12 @@ struct tnode *pow2(tree) register struct tnode *tree; { break; case PTOI: - if (i==1 && tree->tn_tr1->t_op==MINUS && !isconstant(((struct tnode *)tree->tn_tr1)->tn_tr2)) { + if (i==1 && tree->tn_tr1->n_op==MINUS && !isconstant(((struct tnode *)tree->tn_tr1)->tn_tr2)) { tree->tn_op = PTOI1; - tree->tn_tr1 = (struct tree *)tnode(LTOI, INT, tree->tn_tr1, TNULL); + tree->tn_tr1 = (struct node *)tnode(LTOI, INT, tree->tn_tr1, (struct node *)NULL); /* in this case optim() is guaranteed to return a struct tnode */ - /* return((struct tnode *)optim((struct tree *)tree));*/ - tree = (struct tnode *)optim((struct tree *)tree); + /* return((struct tnode *)optim((struct node *)tree));*/ + tree = (struct tnode *)optim((struct node *)tree); if (opdope1[tree->tn_op] & LEAF) abort(); return tree; } @@ -538,7 +553,7 @@ struct tnode *pow2(tree) register struct tnode *tree; { ((struct cnode *)tree->tn_tr2)->cn_value = -i; i = tree->tn_type; tree->tn_type = LONG; - tree = tnode(LTOI, i, (struct tree *)tree, TNULL); + tree = tnode(LTOI, i, (struct node *)tree, (struct node *)NULL); break; case DIVIDE: @@ -565,20 +580,20 @@ struct tnode *pow2(tree) register struct tnode *tree; { error1("pow2 botch"); } /* in this case optim() is guaranteed to return a struct tnode */ - tree = (struct tnode *)optim((struct tree *)tree); + tree = (struct tnode *)optim((struct node *)tree); if (opdope1[tree->tn_op] & LEAF) abort(); } return(tree); } -void cbranch1(atree, lbl, cond, reg) struct tree *atree; register int lbl; int cond; register int reg; { +void cbranch1(atree, lbl, cond, reg) struct node *atree; register int lbl; int cond; register int reg; { int l1, op; - register struct tree *tree; + register struct node *tree; again: if ((tree=atree)==NULL) return; - switch(tree->t_op) { + switch(tree->n_op) { case LOGAND: #define ttree ((struct tnode *)tree) @@ -637,9 +652,9 @@ again: #undef ttree } - op = tree->t_op; + op = tree->n_op; if (opdope1[op]&RELAT - && ((struct tnode *)tree)->tn_tr1->t_op==ITOL && ((struct tnode *)tree)->tn_tr2->t_op==ITOL + && ((struct tnode *)tree)->tn_tr1->n_op==ITOL && ((struct tnode *)tree)->tn_tr2->n_op==ITOL && uns(((struct tnode *)((struct tnode *)tree)->tn_tr1)->tn_tr1) == uns(((struct tnode *)((struct tnode *)tree)->tn_tr2)->tn_tr1)) { #define ttree ((struct tnode *)tree) ttree->tn_tr1 = ((struct tnode *)ttree->tn_tr1)->tn_tr1; @@ -649,20 +664,20 @@ again: ttree->tn_op = op = op+LESSEQP-LESSEQ; #undef ttree } - if (tree->t_type==LONG || tree->t_type==UNLONG - || opdope1[op]&RELAT&&(((struct tnode *)tree)->tn_tr1->t_type==LONG || ((struct tnode *)tree)->tn_tr1->t_type==UNLONG)) { + if (tree->n_type==LONG || tree->n_type==UNLONG + || opdope1[op]&RELAT&&(((struct tnode *)tree)->tn_tr1->n_type==LONG || ((struct tnode *)tree)->tn_tr1->n_type==UNLONG)) { #define ttree ((struct tnode *)tree) longrel(ttree, lbl, cond, reg); return; #undef ttree } rcexpr1(tree, cctab, reg); - op = tree->t_op; + op = tree->n_op; if ((opdope1[op]&RELAT)==0) op = NEQUAL; else { #define ttree ((struct tnode *)tree) - l1 = ttree->tn_tr2->t_op; + l1 = ttree->tn_tr2->n_op; if ((l1==CON || l1==SFCON) && ((struct cnode *)ttree->tn_tr2)->cn_value==0) op += 200; /* special for ptr tests */ else @@ -670,7 +685,7 @@ again: #undef ttree } if (isfloat(tree)) - fprintf(temp_fp[temp_fi], /*printf(*/"cfcc\n"); + fprintf(temp_fp[temp_fi], "cfcc\n"); branch1(lbl, op, !cond); } @@ -681,13 +696,13 @@ void branch1(lbl, aop, c) int lbl; int aop; int c; { if(op = aop) { skip = prins(op, c, branchtab, lbl); } else { - fprintf(temp_fp[temp_fi], /*printf(*/"jbr"); + fprintf(temp_fp[temp_fi], "jbr"); skip = 0; } if (skip) - fprintf(temp_fp[temp_fi], /*printf(*/"\tL%d\nL%d:", lbl, skip); + fprintf(temp_fp[temp_fi], "\tL%d\nL%d:", lbl, skip); else - fprintf(temp_fp[temp_fi], /*printf(*/"\tL%d\n", lbl); + fprintf(temp_fp[temp_fi], "\tL%d\n", lbl); } void longrel(atree, lbl, cond, reg) struct tnode *atree; int lbl; int cond; int reg; { @@ -697,7 +712,7 @@ void longrel(atree, lbl, cond, reg) struct tnode *atree; int lbl; int cond; int if (reg&01) reg++; - reorder((struct tree **)&atree, cctab, reg); + reorder((struct node **)&atree, cctab, reg); /* in this case reorder is guaranteed to return a struct tnode */ if (opdope1[atree->tn_op] & LEAF) abort(); tree = atree; @@ -716,15 +731,15 @@ void longrel(atree, lbl, cond, reg) struct tnode *atree; int lbl; int cond; int xlab2 = 0; xop = op; xz = xzero; - xzero = !isrel || (tree->tn_tr2->t_op==ITOL && ((struct tnode *)tree->tn_tr2)->tn_tr1->t_op==CON + xzero = !isrel || (tree->tn_tr2->n_op==ITOL && ((struct tnode *)tree->tn_tr2)->tn_tr1->n_op==CON && ((struct cnode *)((struct tnode *)tree->tn_tr2)->tn_tr1)->cn_value==0); if (tree->tn_op==ANDN) { tree->tn_op = TAND; - tree->tn_tr2 = optim((struct tree *)tnode(COMPL, LONG, tree->tn_tr2, TNULL)); + tree->tn_tr2 = optim((struct node *)tnode(COMPL, LONG, tree->tn_tr2, (struct node *)NULL)); } - if (cexpr((struct tree *)tree, cctab, reg) < 0) { - reg = rcexpr1((struct tree *)tree, regtab, reg); - fprintf(temp_fp[temp_fi], /*printf(*/"ashc $0,r%d\n", reg); + if (cexpr((struct node *)tree, cctab, reg) < 0) { + reg = rcexpr1((struct node *)tree, regtab, reg); + fprintf(temp_fp[temp_fi], "ashc $0,r%d\n", reg); branch1(xlab1, op, 0); } xlab1 = xl1; @@ -793,7 +808,7 @@ int xlongrel(f) int f; { } void label1(l) int l; { - fprintf(temp_fp[temp_fi], /*printf(*/"L%d:", l); + fprintf(temp_fp[temp_fi], "L%d:", l); } void popstk(a) int a; { @@ -803,14 +818,14 @@ void popstk(a) int a; { return; case 2: - fprintf(temp_fp[temp_fi], /*printf(*/"tst (sp)+\n"); + fprintf(temp_fp[temp_fi], "tst (sp)+\n"); return; case 4: - fprintf(temp_fp[temp_fi], /*printf(*/"cmp (sp)+,(sp)+\n"); + fprintf(temp_fp[temp_fi], "cmp (sp)+,(sp)+\n"); return; } - fprintf(temp_fp[temp_fi], /*printf(*/"add $%o,sp\n", UNS(a)); + fprintf(temp_fp[temp_fi], "add $%o,sp\n", UNS(a)); } void werror1(s) char *s; { @@ -844,7 +859,7 @@ void psoct(an) int an; { n = -n; sign = "-"; } - fprintf(temp_fp[temp_fi], /*printf(*/"%s%o", sign, n); + fprintf(temp_fp[temp_fi], "%s%o", sign, n); } /* @@ -863,10 +878,10 @@ void outcode(fmt, va_alist) char *fmt; va_dcl #endif { va_list argp; - /* struct tree *expstack[STKS], **sp;*/ - static struct tree *expstack[STKS], **sp = expstack; + /* struct node *expstack[STKS], **sp;*/ + static struct node *expstack[STKS], **sp = expstack; #if 0 /* bitrot */ - register struct tree *tp; + register struct node *tp; #endif register int t, op; char s[80]; /* big for asm() stuff & long variable names */ @@ -896,7 +911,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl switch(op &= 0377) { case SINIT: - fprintf(temp_fp[temp_fi], /*printf(*/"%o\n", UNS(va_arg(argp, int) /*geti()*/)); + fprintf(temp_fp[temp_fi], "%o\n", UNS(va_arg(argp, int) /*geti()*/)); break; case EOFC: @@ -905,90 +920,90 @@ void outcode(fmt, va_alist) char *fmt; va_dcl case BDATA: if (va_arg(argp, int) /*geti()*/ == 1) { - fprintf(temp_fp[temp_fi], /*printf(*/".byte "); + fprintf(temp_fp[temp_fi], ".byte "); for (;;) { - fprintf(temp_fp[temp_fi], /*printf(*/"%o", UNS(va_arg(argp, int) /*geti()*/)); + fprintf(temp_fp[temp_fi], "%o", UNS(va_arg(argp, int) /*geti()*/)); if (va_arg(argp, int) /*geti()*/ != 1) break; - fprintf(temp_fp[temp_fi], /*printf(*/","); + fprintf(temp_fp[temp_fi], ","); } - fprintf(temp_fp[temp_fi], /*printf(*/"\n"); + fprintf(temp_fp[temp_fi], "\n"); } break; case PROG: - fprintf(temp_fp[temp_fi], /*printf(*/".text\n"); + fprintf(temp_fp[temp_fi], ".text\n"); break; case DATA: - fprintf(temp_fp[temp_fi], /*printf(*/".data\n"); + fprintf(temp_fp[temp_fi], ".data\n"); break; case BSS: - fprintf(temp_fp[temp_fi], /*printf(*/".bss\n"); + fprintf(temp_fp[temp_fi], ".bss\n"); break; case SYMDEF: outname(s/*)*/, va_arg(argp, char *)); - fprintf(temp_fp[temp_fi], /*printf(*/".globl\t%s\n", s); - sfuncr.nn_nloc = 0; + fprintf(temp_fp[temp_fi], ".globl\t%s\n", s); + sfuncr.locnn_nloc = 0; break; case RETRN: - fprintf(temp_fp[temp_fi], /*printf(*/"jmp\tcret\n"); + fprintf(temp_fp[temp_fi], "jmp\tcret\n"); break; case CSPACE: outname(s/*)*/, va_arg(argp, char *)); - fprintf(temp_fp[temp_fi], /*printf(*/".comm\t%s,%o\n", s, UNS(va_arg(argp, int) /*geti()*/)); + fprintf(temp_fp[temp_fi], ".comm\t%s,%o\n", s, UNS(va_arg(argp, int) /*geti()*/)); break; case SSPACE: - fprintf(temp_fp[temp_fi], /*printf(*/".=.+%o\n", UNS(t=va_arg(argp, int) /*geti()*/)); + fprintf(temp_fp[temp_fi], ".=.+%o\n", UNS(t=va_arg(argp, int) /*geti()*/)); totspace += (_UNSIGNED_INT)t; break; case EVEN: - fprintf(temp_fp[temp_fi], /*printf(*/".even\n"); + fprintf(temp_fp[temp_fi], ".even\n"); break; case SAVE: - fprintf(temp_fp[temp_fi], /*printf(*/"jsr r5,csv\n"); + fprintf(temp_fp[temp_fi], "jsr r5,csv\n"); break; case SETSTK: t = va_arg(argp, int) /*geti()*/; if (t==2) - fprintf(temp_fp[temp_fi], /*printf(*/"tst -(sp)\n"); + fprintf(temp_fp[temp_fi], "tst -(sp)\n"); else if (t != 0) - fprintf(temp_fp[temp_fi], /*printf(*/"sub $%o,sp\n", UNS(t)); + fprintf(temp_fp[temp_fi], "sub $%o,sp\n", UNS(t)); break; case PROFIL: t = va_arg(argp, int) /*geti()*/; outname(s/*)*/, va_arg(argp, char *)); - fprintf(temp_fp[temp_fi], /*printf(*/"mov $L%d,r0\njsr pc,mcount\n", t); - fprintf(temp_fp[temp_fi], /*printf(*/".data\nL%d:%s+1\n.text\n", t, s); + fprintf(temp_fp[temp_fi], "mov $L%d,r0\njsr pc,mcount\n", t); + fprintf(temp_fp[temp_fi], ".data\nL%d:%s+1\n.text\n", t, s); break; case ASSEM: outname(s/*)*/, va_arg(argp, char *)); - fprintf(temp_fp[temp_fi], /*printf(*/"%s\n", s); + fprintf(temp_fp[temp_fi], "%s\n", s); break; case SNAME: outname(s/*)*/, va_arg(argp, char *)); - fprintf(temp_fp[temp_fi], /*printf(*/"~%s=L%d\n", s+1, va_arg(argp, int) /*geti()*/); + fprintf(temp_fp[temp_fi], "~%s=L%d\n", s+1, va_arg(argp, int) /*geti()*/); break; case ANAME: outname(s/*)*/, va_arg(argp, char *)); - fprintf(temp_fp[temp_fi], /*printf(*/"~%s=%o\n", s+1, UNS(va_arg(argp, int) /*geti()*/)); + fprintf(temp_fp[temp_fi], "~%s=%o\n", s+1, UNS(va_arg(argp, int) /*geti()*/)); break; case RNAME: outname(s/*)*/, va_arg(argp, char *)); - fprintf(temp_fp[temp_fi], /*printf(*/"~%s=r%d\n", s+1, va_arg(argp, int) /*geti()*/); + fprintf(temp_fp[temp_fi], "~%s=r%d\n", s+1, va_arg(argp, int) /*geti()*/); break; case SWIT: @@ -1036,15 +1051,15 @@ void outcode(fmt, va_alist) char *fmt; va_dcl rcexpr1(tp, efftab, 0); else { if (tp->tn_type==LONG || tp->tn_type==UNLONG) { - rcexpr1(tnode(RFORCE, tp->tn_type, tp, TNULL), efftab, 0); - fprintf(temp_fp[temp_fi], /*printf(*/"ashc $0,r0\n"); + rcexpr1(tnode(RFORCE, tp->tn_type, tp, (struct node *)NULL), efftab, 0); + fprintf(temp_fp[temp_fi], "ashc $0,r0\n"); } else { rcexpr1(tp, cctab, 0); if (isfloat(tp)) - fprintf(temp_fp[temp_fi], /*printf(*/"cfcc\n"); + fprintf(temp_fp[temp_fi], "cfcc\n"); } - fprintf(temp_fp[temp_fi], /*printf(*/"jgt L%d\n", lbl3); - fprintf(temp_fp[temp_fi], /*printf(*/"jlt L%d\njbr L%d\n", lbl, lbl2); + fprintf(temp_fp[temp_fi], "jgt L%d\n", lbl3); + fprintf(temp_fp[temp_fi], "jlt L%d\njbr L%d\n", lbl, lbl2); } /* curbase = funcbase;*/ break; @@ -1079,7 +1094,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++ = (struct tree *)tnode(ITOL, LONG, tconst(op, INT), TNULL); + *sp++ = (struct node *)tnode(ITOL, LONG, tconst(op, INT), (struct node *)NULL); break; } tp = getblk(sizeof(struct lnode)); @@ -1105,9 +1120,9 @@ void outcode(fmt, va_alist) char *fmt; va_dcl break; case FSEL: - tp = tnode(FSEL, va_arg(argp, int) /*geti()*/, *--sp, TNULL); + tp = tnode(FSEL, va_arg(argp, int) /*geti()*/, *--sp, (struct node *)NULL); t = va_arg(argp, int) /*geti()*/; - tp->tn_tr2 = (struct tree *)tnode(COMMA, INT, tconst(va_arg(argp, int) /*geti()*/, INT), tconst(t, INT)); + tp->tn_tr2 = (struct node *)tnode(COMMA, INT, tconst(va_arg(argp, int) /*geti()*/, INT), tconst(t, INT)); if (tp->tn_tr2->tn_tr1->cn_value==16) tp = paint(tp->tn_tr1, tp->tn_type); *sp++ = tp; @@ -1124,7 +1139,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl break; case NULLOP: - *sp++ = tnode(0, 0, TNULL, TNULL); + *sp++ = tnode(0, 0, (struct node *)NULL, (struct node *)NULL); break; #endif @@ -1134,12 +1149,12 @@ void outcode(fmt, va_alist) char *fmt; va_dcl case NLABEL: outname(s/*)*/, va_arg(argp, char *)); - fprintf(temp_fp[temp_fi], /*printf(*/"%s:\n", s); + fprintf(temp_fp[temp_fi], "%s:\n", s); break; case RLABEL: outname(s/*)*/, va_arg(argp, char *)); - fprintf(temp_fp[temp_fi], /*printf(*/"%s:\n~~%s:\n", s, s+1); + fprintf(temp_fp[temp_fi], "%s:\n~~%s:\n", s, s+1); break; case BRANCH: @@ -1166,7 +1181,7 @@ void outcode(fmt, va_alist) char *fmt; va_dcl *sp++ = tnode(op, va_arg(argp, int) /*geti()*/, *--sp, tp); #endif } else - sp[-1] = tnode(op, va_arg(argp, int) /*geti()*/, sp[-1], TNULL); + sp[-1] = tnode(op, va_arg(argp, int) /*geti()*/, sp[-1], (struct node *)NULL); break; #endif } @@ -1222,15 +1237,15 @@ void strasg(atp) struct tnode *atp; { } if (tp->tn_op != ASSIGN) {*/ if (tp->tn_op==RFORCE) { /* function return */ - if (sfuncr.nn_nloc==0) { - sfuncr.nn_nloc = isn1++; - fprintf(temp_fp[temp_fi], /*printf(*/".bss\nL%d:.=.+%o\n.text\n", sfuncr.nn_nloc, + if (sfuncr.locnn_nloc==0) { + sfuncr.locnn_nloc = isn1++; + fprintf(temp_fp[temp_fi], ".bss\nL%d:.=.+%o\n.text\n", sfuncr.locnn_nloc, UNS(nwords*sizeof(_INT))); } - atp/*->tn_tr1*/ = tnode(ASSIGN, STRUCT, (struct tree *)&sfuncr, tp->tn_tr1); + atp/*->tn_tr1*/ = tnode(ASSIGN, STRUCT, (struct node *)&sfuncr, tp->tn_tr1); atp->tn_strp = tp->tn_strp; strasg(atp); - fprintf(temp_fp[temp_fi], /*printf(*/"mov $L%d,r0\n", sfuncr.nn_nloc); + fprintf(temp_fp[temp_fi], "mov $L%d,r0\n", sfuncr.locnn_nloc); return; } /* if (tp->tn_op==CALL) { @@ -1242,35 +1257,35 @@ void strasg(atp) struct tnode *atp; { }*/ tp->tn_tr2 = strfunc(tp->tn_tr2); if (nwords==1) - paint((struct tree *)tp, INT); + paint((struct node *)tp, INT); else if (nwords==sizeof(_INT)) - paint((struct tree *)tp, LONG); + paint((struct node *)tp, LONG); else { - if (tp->tn_tr1->t_op!=NAME && tp->tn_tr1->t_op!=STAR - || tp->tn_tr2->t_op!=NAME && tp->tn_tr2->t_op!=STAR) { + if (tp->tn_tr1->n_op!=NAME && tp->tn_tr1->n_op!=STAR + || tp->tn_tr2->n_op!=NAME && tp->tn_tr2->n_op!=STAR) { error1("unimplemented structure assignment"); return; } - tp->tn_tr1 = (struct tree *)tnode(AMPER, STRUCT+PTR, tp->tn_tr1, TNULL); - tp->tn_tr2 = (struct tree *)tnode(AMPER, STRUCT+PTR, tp->tn_tr2, TNULL); + tp->tn_tr1 = (struct node *)tnode(AMPER, STRUCT+PTR, tp->tn_tr1, (struct node *)NULL); + tp->tn_tr2 = (struct node *)tnode(AMPER, STRUCT+PTR, tp->tn_tr2, (struct node *)NULL); tp->tn_op = STRSET; tp->tn_type = STRUCT+PTR; - rcexpr1(optim((struct tree *)tp), efftab, 0); + rcexpr1(optim((struct node *)tp), efftab, 0); if (nwords < 7) { for (i=0; i(b))?(a):(b)) -struct tree *optim(tree) register struct tree *tree; { +struct node *optim(tree) register struct node *tree; { register int op, dope; #ifdef pdp11 union { double dv; _INT iv[4];} fp11; @@ -21,14 +21,14 @@ struct tree *optim(tree) register struct tree *tree; { if (tree==NULL) return(NULL); - if ((op = tree->t_op)==0) + if ((op = tree->n_op)==0) return(tree); if (op==NAME && ((struct nnode *)tree)->nn_class==AUTO) { -#define ntree ((struct nnode *)tree) - ntree->nn_class = OFFS; - ntree->nn_regno = 5; - ntree->nn_offset = ntree->nn_nloc; -#undef ntree +#define locntree ((struct locnnode *)tree) + locntree->locnn_class = OFFS; + locntree->locnn_regno = 5; + locntree->locnn_offset = locntree->locnn_nloc; +#undef locntree } dope = opdope1[op]; if ((dope&LEAF) != 0) { @@ -59,10 +59,10 @@ struct tree *optim(tree) register struct tree *tree; { } /* in reality this can only be called with a struct tnode argument */ -struct tree *binoptim(tree) register struct tree *tree; { +struct node *binoptim(tree) register struct node *tree; { register int op, dope; int d1, d2; - struct tree *t; + struct node *t; #define ttree ((struct tnode *)tree) if (ttree->tn_type==CHAR) @@ -75,7 +75,7 @@ struct tree *binoptim(tree) register struct tree *tree; { */ case ASAND: ttree->tn_op = ASANDN; - ttree->tn_tr2 = (struct tree *)tnode(COMPL, ttree->tn_tr2->t_type, ttree->tn_tr2, TNULL); + ttree->tn_tr2 = (struct node *)tnode(COMPL, ttree->tn_tr2->n_type, ttree->tn_tr2, (struct node *)NULL); break; /* @@ -84,17 +84,17 @@ struct tree *binoptim(tree) register struct tree *tree; { */ case LTOP: ttree->tn_op = ITOP; - ttree->tn_tr1 = unoptim((struct tree *)tnode(LTOI,INT,ttree->tn_tr1, TNULL)); + ttree->tn_tr1 = unoptim((struct node *)tnode(LTOI,INT,ttree->tn_tr1, (struct node *)NULL)); case ITOP: ttree->tn_op = TIMES; break; case MINUS: - if ((t = isconstant(ttree->tn_tr2)) && (!uns(t) || ttree->tn_type!=LONG) + if ((t = (struct node *)isconstant(ttree->tn_tr2)) && (!uns(t) || ttree->tn_type!=LONG) /* I don't think the following test matters since -0100000 == 0100000 */ - && (t->t_type!=INT || ((struct cnode *)t)->cn_value!=(_INT)0100000)) { + && (((struct cnode *)t)->cn_type!=INT || ((struct cnode *)t)->cn_value!=(_INT)0100000)) { ttree->tn_op = PLUS; - if (t->t_type==DOUBLE) { + if (t->n_type==DOUBLE) { /* here it's an SFCON, so fn_value is filled in instead of fn_fvalue */ /* PDP-11 FP representation */ ((struct fnode *)t)->fn_value ^= 0100000; @@ -105,69 +105,69 @@ struct tree *binoptim(tree) register struct tree *tree; { } op = ttree->tn_op; dope = opdope1[op]; - if (dope&LVALUE && ttree->tn_tr1->t_op==FSEL) + if (dope&LVALUE && ttree->tn_tr1->n_op==FSEL) return(lvfield(ttree)); if ((dope&COMMUTE)!=0) { d1 = ttree->tn_type; #undef ttree tree = acommute(tree); - if (tree->t_op == op) - tree->t_type = d1; + if (tree->n_op == op) + tree->n_type = d1; /* * PDP-11 special: * replace a&b by a ANDN ~ b. * This will be undone when in * truth-value context. */ - if (tree->t_op!=AND) + if (tree->n_op!=AND) return(tree); #define ttree ((struct tnode *)tree) /* * long & pos-int is simpler */ - if ((ttree->tn_type==LONG || ttree->tn_type==UNLONG) && ttree->tn_tr2->t_op==ITOL - && (((struct tnode *)ttree->tn_tr2)->tn_tr1->t_op==CON && ((struct cnode *)((struct tnode *)ttree->tn_tr2)->tn_tr1)->cn_value>=0 + if ((ttree->tn_type==LONG || ttree->tn_type==UNLONG) && ttree->tn_tr2->n_op==ITOL + && (((struct tnode *)ttree->tn_tr2)->tn_tr1->n_op==CON && ((struct cnode *)((struct tnode *)ttree->tn_tr2)->tn_tr1)->cn_value>=0 || uns(((struct tnode *)ttree->tn_tr2)->tn_tr1))) { ttree->tn_type = UNSIGN; t = ttree->tn_tr2; ttree->tn_tr2 = ((struct tnode *)ttree->tn_tr2)->tn_tr1; - ((struct tnode *)t)->tn_tr1 = (struct tree *)ttree; - ttree->tn_tr1 = (struct tree *)tnode(LTOI, UNSIGN, ttree->tn_tr1, TNULL); + ((struct tnode *)t)->tn_tr1 = (struct node *)ttree; + ttree->tn_tr1 = (struct node *)tnode(LTOI, UNSIGN, ttree->tn_tr1, (struct node *)NULL); return(optim(t)); } /* * Keep constants to the right */ - if ((ttree->tn_tr1->t_op==ITOL && ((struct tnode *)ttree->tn_tr1)->tn_tr1->t_op==CON) - || ttree->tn_tr1->t_op==LCON) { + if ((ttree->tn_tr1->n_op==ITOL && ((struct tnode *)ttree->tn_tr1)->tn_tr1->n_op==CON) + || ttree->tn_tr1->n_op==LCON) { t = ttree->tn_tr1; ttree->tn_tr1 = ttree->tn_tr2; ttree->tn_tr2 = t; } ttree->tn_op = ANDN; op = ANDN; - ttree->tn_tr2 = (struct tree *)tnode(COMPL, ttree->tn_tr2->t_type, ttree->tn_tr2, TNULL); + ttree->tn_tr2 = (struct node *)tnode(COMPL, ttree->tn_tr2->n_type, ttree->tn_tr2, (struct node *)NULL); } again: ttree->tn_tr1 = optim(ttree->tn_tr1); ttree->tn_tr2 = optim(ttree->tn_tr2); if (ttree->tn_type == LONG || ttree->tn_type==UNLONG) { - t = (struct tree *)lconst(ttree->tn_op, ttree->tn_tr1, ttree->tn_tr2); + t = (struct node *)lconst(ttree->tn_op, ttree->tn_tr1, ttree->tn_tr2); if (t) return(t); } if ((dope&RELAT) != 0) { if ((d1=degree(ttree->tn_tr1)) < (d2=degree(ttree->tn_tr2)) - || d1==d2 && ttree->tn_tr1->t_op==NAME && ttree->tn_tr2->t_op!=NAME) { + || d1==d2 && ttree->tn_tr1->n_op==NAME && ttree->tn_tr2->n_op!=NAME) { t = ttree->tn_tr1; ttree->tn_tr1 = ttree->tn_tr2; ttree->tn_tr2 = t; ttree->tn_op = maprel[op-EQUAL]; } - if (ttree->tn_tr1->t_type==CHAR && ttree->tn_tr2->t_op==CON - && (dcalc(ttree->tn_tr1, 0) <= 12 || ttree->tn_tr1->t_op==STAR) + if (ttree->tn_tr1->n_type==CHAR && ttree->tn_tr2->n_op==CON + && (dcalc(ttree->tn_tr1, 0) <= 12 || ttree->tn_tr1->n_op==STAR) && ((struct cnode *)ttree->tn_tr2)->cn_value <= 127 && ((struct cnode *)ttree->tn_tr2)->cn_value >= 0) - ttree->tn_tr2->t_type = CHAR; + ttree->tn_tr2->n_type = CHAR; } d1 = max(degree(ttree->tn_tr1), islong(ttree->tn_type)); d2 = max(degree(ttree->tn_tr2), 0); @@ -178,14 +178,14 @@ struct tree *binoptim(tree) register struct tree *tree; { */ case FSELA: #define Ftree ((struct fasgn *)ttree) - if (Ftree->fa_tr2->t_op==CON && ((struct cnode *)Ftree->fa_tr2)->cn_value==0) { + if (Ftree->fa_tr2->n_op==CON && ((struct cnode *)Ftree->fa_tr2)->cn_value==0) { Ftree->fa_op = ASAND; ((struct cnode *)Ftree->fa_tr2)->cn_value = ~Ftree->fa_mask; - return(optim((struct tree *)Ftree)); + return(optim((struct node *)Ftree)); } - if (Ftree->fa_tr2->t_op==CON && Ftree->fa_mask==((struct cnode *)Ftree->fa_tr2)->cn_value) { + if (Ftree->fa_tr2->n_op==CON && Ftree->fa_mask==((struct cnode *)Ftree->fa_tr2)->cn_value) { Ftree->fa_op = ASOR; - return(optim((struct tree *)Ftree)); + return(optim((struct node *)Ftree)); } #undef Ftree @@ -227,15 +227,15 @@ struct tree *binoptim(tree) register struct tree *tree; { case DIVIDE: case ASDIV: case ASTIMES: - if (ttree->tn_tr2->t_op==CON && ((struct cnode *)ttree->tn_tr2)->cn_value==1) { + if (ttree->tn_tr2->n_op==CON && ((struct cnode *)ttree->tn_tr2)->cn_value==1) { if (op==PTOI) - return(optim((struct tree *)tnode(LTOI,INT,paint(ttree->tn_tr1,LONG), TNULL))); + return(optim((struct node *)tnode(LTOI,INT,paint(ttree->tn_tr1,LONG), (struct node *)NULL))); return(paint(ttree->tn_tr1, ttree->tn_type)); } case MOD: case ASMOD: if ((uns(ttree->tn_tr1) || ttree->tn_op==PTOI) && ispow2(ttree)) - return((struct tree *)pow2(ttree)); + return((struct node *)pow2(ttree)); if ((op==MOD||op==ASMOD) && ttree->tn_type==DOUBLE) { error1("Floating %% not defined"); ttree->tn_type = INT; @@ -246,10 +246,10 @@ struct tree *binoptim(tree) register struct tree *tree; { d2 += 2 + regpanic; panicposs++; if (ttree->tn_type==LONG || ttree->tn_type==UNLONG) - return(hardlongs((struct tree *)ttree)); + return(hardlongs((struct node *)ttree)); if ((op==MOD || op==DIVIDE || op==ASMOD || op==ASDIV) && (uns(ttree->tn_tr1) || uns(ttree->tn_tr2)) - && (ttree->tn_tr2->t_op!=CON || ((struct cnode *)ttree->tn_tr2)->cn_value<=1)) { + && (ttree->tn_tr2->n_op!=CON || ((struct cnode *)ttree->tn_tr2)->cn_value<=1)) { if (op>=ASDIV) { ttree->tn_op += ASUDIV - ASDIV; } else @@ -260,7 +260,7 @@ struct tree *binoptim(tree) register struct tree *tree; { case ASPLUS: case ASMINUS: - if (ttree->tn_tr2->t_op==CON && ((struct cnode *)ttree->tn_tr2)->cn_value==0) + if (ttree->tn_tr2->n_op==CON && ((struct cnode *)ttree->tn_tr2)->cn_value==0) return(ttree->tn_tr1); goto def; @@ -268,7 +268,7 @@ struct tree *binoptim(tree) register struct tree *tree; { case RSHIFT: case ASRSH: case ASLSH: - if (ttree->tn_tr2->t_op==CON && ((struct cnode *)ttree->tn_tr2)->cn_value==0) + if (ttree->tn_tr2->n_op==CON && ((struct cnode *)ttree->tn_tr2)->cn_value==0) return(paint(ttree->tn_tr1, ttree->tn_type)); /* * PDP-11 special: turn right shifts into negative @@ -280,12 +280,12 @@ struct tree *binoptim(tree) register struct tree *tree; { } if (op==LSHIFT||op==ASLSH) goto constant; - if (ttree->tn_tr2->t_op==CON && ((struct cnode *)ttree->tn_tr2)->cn_value==1 + if (ttree->tn_tr2->n_op==CON && ((struct cnode *)ttree->tn_tr2)->cn_value==1 && !uns(ttree->tn_tr1) && !uns(ttree->tn_tr2)) goto constant; op += (LSHIFT-RSHIFT); ttree->tn_op = op; - ttree->tn_tr2 = (struct tree *)tnode(NEG, ttree->tn_tr2->t_type, ttree->tn_tr2, TNULL); + ttree->tn_tr2 = (struct node *)tnode(NEG, ttree->tn_tr2->n_type, ttree->tn_tr2, (struct node *)NULL); if (uns(ttree->tn_tr1) || uns(ttree->tn_tr2)) { if (ttree->tn_op==LSHIFT) ttree->tn_op = ULSH; @@ -295,7 +295,7 @@ struct tree *binoptim(tree) register struct tree *tree; { goto again; constant: - if (ttree->tn_tr1->t_op==CON && ttree->tn_tr2->t_op==CON) { + if (ttree->tn_tr1->n_op==CON && ttree->tn_tr2->n_op==CON) { _const(op, &((struct cnode *)ttree->tn_tr1)->cn_value, ((struct cnode *)ttree->tn_tr2)->cn_value, ttree->tn_type); return(ttree->tn_tr1); } @@ -304,18 +304,18 @@ struct tree *binoptim(tree) register struct tree *tree; { def: default: if (dope&RELAT) { - if (ttree->tn_tr1->t_type==LONG || ttree->tn_tr1->t_type==UNLONG) /* long relations are a mess */ + if (ttree->tn_tr1->n_type==LONG || ttree->tn_tr1->n_type==UNLONG) /* long relations are a mess */ d1 = 10; - if (opdope1[ttree->tn_tr1->t_op]&RELAT && ttree->tn_tr2->t_op==CON + if (opdope1[ttree->tn_tr1->n_op]&RELAT && ttree->tn_tr2->n_op==CON && ((struct cnode *)ttree->tn_tr2)->cn_value==0) { switch(op) { case GREATEQ: - return((struct tree *)&cone); + return((struct node *)&cone); case LESS: - return((struct tree *)&czero); + return((struct node *)&czero); case LESSEQ: case EQUAL: - ttree->tn_tr1->t_op = notrel[ttree->tn_tr1->t_op-EQUAL]; + ttree->tn_tr1->n_op = notrel[ttree->tn_tr1->n_op-EQUAL]; } return(ttree->tn_tr1); } @@ -323,20 +323,20 @@ struct tree *binoptim(tree) register struct tree *tree; { ttree->tn_degree = d1==d2? d1+islong(ttree->tn_type): max(d1, d2); break; } - return((struct tree *)ttree); + return((struct node *)ttree); } /* in reality this can only be called with a struct tnode argument */ -struct tree *unoptim(tree) register struct tree *tree; { - register struct tree *subtre, *p; +struct node *unoptim(tree) register struct node *tree; { + register struct node *subtre, *p; #define ttree ((struct tnode *)tree) if (ttree==NULL) return(NULL); again: - if (ttree->tn_op==AMPER && ttree->tn_tr1->t_op==STAR) { + if (ttree->tn_op==AMPER && ttree->tn_tr1->n_op==STAR) { subtre = ((struct tnode *)ttree->tn_tr1)->tn_tr1; - subtre->t_type = ttree->tn_type; + subtre->n_type = ttree->tn_type; return(optim(subtre)); } subtre = ttree->tn_tr1 = optim(ttree->tn_tr1); @@ -344,12 +344,12 @@ struct tree *unoptim(tree) register struct tree *tree; { case INCAFT: case DECAFT: - if (ttree->tn_type!=subtre->t_type) + if (ttree->tn_type!=subtre->n_type) paint(subtre, ttree->tn_type); break; case ITOL: - if (subtre->t_op==CON && subtre->t_type==INT && ((struct cnode *)subtre)->cn_value<0) { + if (subtre->n_op==CON && subtre->n_type==INT && ((struct cnode *)subtre)->cn_value<0) { #undef ttree #define csubtre ((struct cnode *)subtre) tree = getblk(sizeof(struct lnode)); @@ -357,7 +357,7 @@ struct tree *unoptim(tree) register struct tree *tree; { ltree->ln_op = LCON; ltree->ln_type = LONG; ltree->ln_lvalue = csubtre->cn_value; - return((struct tree *)ltree); + return((struct node *)ltree); #define ttree ((struct tnode *)tree) #undef csubtre #undef ltree @@ -365,15 +365,15 @@ struct tree *unoptim(tree) register struct tree *tree; { break; case FTOI: - if (uns((struct tree *)ttree)) { + if (uns((struct node *)ttree)) { ttree->tn_op = FTOL; ttree->tn_type = LONG; - /*t*/tree = (struct tree *)tnode(LTOI, UNSIGN, (struct tree *)ttree, TNULL); + /*t*/tree = (struct node *)tnode(LTOI, UNSIGN, (struct node *)ttree, (struct node *)NULL); } break; case LTOF: - if (subtre->t_op==LCON) { + if (subtre->n_op==LCON) { #undef ttree #define lsubtre ((struct lnode *)subtre) tree = getblk(sizeof(struct fnode)); @@ -386,17 +386,17 @@ struct tree *unoptim(tree) register struct tree *tree; { #else ftree->fn_fvalue = fp_long_to_double(lsubtre->ln_lvalue); #endif - return(optim((struct tree *)ftree)); + return(optim((struct node *)ftree)); #define ttree ((struct tnode *)tree) #undef lsubtre #undef ftree } - if (subtre->t_type==UNLONG) + if (subtre->n_type==UNLONG) ttree->tn_op = ULTOF; break; case ITOF: - if (subtre->t_op==CON) { + if (subtre->n_op==CON) { #undef ttree #define csubtre ((struct cnode *)subtre) tree = getblk(sizeof(struct fnode)); @@ -405,26 +405,26 @@ struct tree *unoptim(tree) register struct tree *tree; { ftree->fn_type = DOUBLE; ftree->fn_value = isn1++; #ifdef pdp11 - if (uns((struct tree *)subtre)) + if (uns((struct node *)subtre)) ftree->fn_fvalue = (_UNSIGNED_INT)csubtre->cn_value; else ftree->fn_fvalue = csubtre->cn_value; #else /* revisit the unsigned case */ - if (uns((struct tree *)subtre)) + if (uns((struct node *)subtre)) ftree->fn_fvalue = fp_long_to_double((_LONG)(_UNSIGNED_INT)csubtre->cn_value); else ftree->fn_fvalue = fp_int_to_double(csubtre->cn_value); #endif - return(optim((struct tree *)ftree)); + return(optim((struct node *)ftree)); #define ttree ((struct tnode *)tree) #undef csubtre #undef ftree } if (uns(subtre)) { - ttree->tn_tr1 = (struct tree *)tnode(ITOL, LONG, subtre, TNULL); + ttree->tn_tr1 = (struct node *)tnode(ITOL, LONG, subtre, (struct node *)NULL); ttree->tn_op = LTOF; - return(optim((struct tree *)ttree)); + return(optim((struct node *)ttree)); } break; @@ -432,42 +432,42 @@ struct tree *unoptim(tree) register struct tree *tree; { /* * Sign-extend PDP-11 characters */ - if (subtre->t_op==CON) { + if (subtre->n_op==CON) { #define csubtre ((struct cnode *)subtre) csubtre->cn_type = ttree->tn_type; csubtre->cn_value = (char)csubtre->cn_value; - return((struct tree *)csubtre); + return((struct node *)csubtre); #undef csubtre - } else if (subtre->t_op==NAME && ttree->tn_type==INT) { - subtre->t_type = CHAR; + } else if (subtre->n_op==NAME && ttree->tn_type==INT) { + subtre->n_type = CHAR; return(subtre); } break; case LTOI: - switch (subtre->t_op) { + switch (subtre->n_op) { case LCON: #define csubtre ((struct cnode *)subtre) csubtre->cn_op = CON; csubtre->cn_type = ttree->tn_type; csubtre->cn_value = ((struct lnode *)csubtre)->ln_lvalue; - return((struct tree *)csubtre); + return((struct node *)csubtre); #undef csubtre case NAME: #define nsubtre ((struct nnode *)subtre) nsubtre->nn_offset += 2; nsubtre->nn_type = ttree->tn_type; - return((struct tree *)nsubtre); + return((struct node *)nsubtre); #undef nsubtre case STAR: #define tsubtre ((struct tnode *)subtre) tsubtre->tn_type = ttree->tn_type; - tsubtre->tn_tr1->t_type = ttree->tn_type+PTR; - tsubtre->tn_tr1 = (struct tree *)tnode(PLUS, ttree->tn_type, tsubtre->tn_tr1, (struct tree *)tconst(2, INT)); - return(optim((struct tree *)tsubtre)); + tsubtre->tn_tr1->n_type = ttree->tn_type+PTR; + tsubtre->tn_tr1 = (struct node *)tnode(PLUS, ttree->tn_type, tsubtre->tn_tr1, (struct node *)tconst(2, INT)); + return(optim((struct node *)tsubtre)); #undef tsubtre case ITOL: @@ -482,12 +482,12 @@ struct tree *unoptim(tree) register struct tree *tree; { case OR: case EXOR: #define tsubtre ((struct tnode *)subtre) - tsubtre->tn_tr2 = (struct tree *)tnode(LTOI, ttree->tn_type, tsubtre->tn_tr2, TNULL); + tsubtre->tn_tr2 = (struct node *)tnode(LTOI, ttree->tn_type, tsubtre->tn_tr2, (struct node *)NULL); case NEG: case COMPL: - tsubtre->tn_tr1 = (struct tree *)tnode(LTOI, ttree->tn_type, tsubtre->tn_tr1, TNULL); + tsubtre->tn_tr1 = (struct node *)tnode(LTOI, ttree->tn_type, tsubtre->tn_tr1, (struct node *)NULL); tsubtre->tn_type = ttree->tn_type; - return(optim((struct tree *)tsubtre)); + return(optim((struct node *)tsubtre)); #undef tsubtre } break; @@ -498,9 +498,9 @@ struct tree *unoptim(tree) register struct tree *tree; { ttree->tn_tr2->tn_tr1 = subtre; ttree->tn_tr2->tn_op = RSHIFT; ttree->tn_tr1->cn_value = (1 << ttree->tn_tr1->cn_value) - 1;*/ - ttree->tn_tr1 = (struct tree *)tconst((1 << ((struct FS *)ttree->tn_tr2)->flen) - 1, INT); - ttree->tn_tr2 = (struct tree *)tnode(RSHIFT, INT, subtre, (struct tree *)tconst(((struct FS *)ttree->tn_tr2)->bitoffs, INT)); - return(optim((struct tree *)ttree)); + ttree->tn_tr1 = (struct node *)tconst((1 << ((struct FS *)ttree->tn_tr2)->flen) - 1, INT); + ttree->tn_tr2 = (struct node *)tnode(RSHIFT, INT, subtre, (struct node *)tconst(((struct FS *)ttree->tn_tr2)->bitoffs, INT)); + return(optim((struct node *)ttree)); case FSELR: ttree->tn_op = LSHIFT; @@ -510,132 +510,132 @@ struct tree *unoptim(tree) register struct tree *tree; { ttree->tn_tr2 = ttree->tn_tr2->tn_tr2; ttree->tn_tr1->tn_tr2 = subtre; ttree->tn_tr1->tn_tr1->cn_value = (1 << ttree->tn_tr1->tn_tr1->cn_value) -1;*/ - ttree->tn_tr1 = (struct tree *)tnode(AND, INT, (struct tree *)tconst((1 << ((struct FS *)ttree->tn_tr2)->flen) - 1, INT), subtre); - ttree->tn_tr2 = (struct tree *)tconst(((struct FS *)ttree->tn_tr2)->bitoffs, INT); - return(optim((struct tree *)ttree)); + ttree->tn_tr1 = (struct node *)tnode(AND, INT, (struct node *)tconst((1 << ((struct FS *)ttree->tn_tr2)->flen) - 1, INT), subtre); + ttree->tn_tr2 = (struct node *)tconst(((struct FS *)ttree->tn_tr2)->bitoffs, INT); + return(optim((struct node *)ttree)); case AMPER: - if (subtre->t_op==STAR) + if (subtre->n_op==STAR) return(((struct tnode *)subtre)->tn_tr1); - if (subtre->t_op==NAME && ((struct nnode *)subtre)->nn_class == OFFS) { -#define nsubtre ((struct nnode *)subtre) - nsubtre->nn_type = ttree->tn_type; + if (subtre->n_op==NAME && ((struct nnode *)subtre)->nn_class == OFFS) { +#define locnsubtre ((struct locnnode *)subtre) + locnsubtre->locnn_type = ttree->tn_type; #undef ttree #define ctree ((struct cnode *)tree) ctree->cn_op = CON; ctree->cn_type = INT; /* the below seems to have been an oversight, probably a harmless one */ /* ctree->cn_degree = 0;*/ - ctree->cn_value = nsubtre->nn_offset; - nsubtre->nn_class = REG; - nsubtre->nn_nloc = nsubtre->nn_regno; - nsubtre->nn_offset = 0; - return(optim((struct tree *)tnode(PLUS, nsubtre->nn_type, (struct tree *)nsubtre, (struct tree *)ctree))); + ctree->cn_value = locnsubtre->locnn_offset; + locnsubtre->locnn_class = REG; + locnsubtre->locnn_nloc = locnsubtre->locnn_regno; + locnsubtre->locnn_offset = 0; + return(optim((struct node *)tnode(PLUS, locnsubtre->locnn_type, (struct node *)locnsubtre, (struct node *)ctree))); #undef nsubtre #define ttree ((struct tnode *)tree) #undef ctree } - if (subtre->t_op==LOAD) { + if (subtre->n_op==LOAD) { ttree->tn_tr1 = ((struct tnode *)subtre)->tn_tr1; goto again; } break; case STAR: - if (subtre->t_op==AMPER) { + if (subtre->n_op==AMPER) { #define tsubtre ((struct tnode *)subtre) - tsubtre->tn_tr1->t_type = ttree->tn_type; + tsubtre->tn_tr1->n_type = ttree->tn_type; return(tsubtre->tn_tr1); #undef tsubtre } if (ttree->tn_type==STRUCT) break; - if (subtre->t_op==NAME && ((struct nnode *)subtre)->nn_class==REG) { -#define nsubtre ((struct nnode *)subtre) - nsubtre->nn_type = ttree->tn_type; - nsubtre->nn_class = OFFS; - nsubtre->nn_regno = nsubtre->nn_nloc; - return((struct tree *)nsubtre); -#undef nsubtre + if (subtre->n_op==NAME && ((struct nnode *)subtre)->nn_class==REG) { +#define locnsubtre ((struct locnnode *)subtre) + locnsubtre->locnn_type = ttree->tn_type; + locnsubtre->locnn_class = OFFS; + locnsubtre->locnn_regno = locnsubtre->locnn_nloc; + return((struct node *)locnsubtre); +#undef locnsubtre } - if ((subtre->t_op==INCAFT||subtre->t_op==DECBEF) + if ((subtre->n_op==INCAFT||subtre->n_op==DECBEF) && ttree->tn_type!=LONG && ttree->tn_type!=UNLONG - && (p = ((struct tnode *)subtre)->tn_tr1)->t_op==NAME && ((struct nnode *)p)->nn_class==REG && ((struct nnode *)p)->nn_type==((struct tnode *)subtre)->tn_type) { + && (p = ((struct tnode *)subtre)->tn_tr1)->n_op==NAME && ((struct nnode *)p)->nn_class==REG && ((struct nnode *)p)->nn_type==((struct tnode *)subtre)->tn_type) { #define tsubtre ((struct tnode *)subtre) #define np ((struct nnode *)p) np->nn_type = ttree->tn_type; np->nn_op = tsubtre->tn_op==INCAFT? AUTOI: AUTOD; - return((struct tree *)p); + return((struct node *)p); #undef tsubtre #undef np } - if (subtre->t_op==PLUS && (p = ((struct tnode *)subtre)->tn_tr1)->t_op==NAME && ((struct nnode *)p)->nn_class==REG) { + if (subtre->n_op==PLUS && (p = ((struct tnode *)subtre)->tn_tr1)->n_op==NAME && ((struct nnode *)p)->nn_class==REG) { #define tsubtre ((struct tnode *)subtre) -#define np ((struct nnode *)p) - if (tsubtre->tn_tr2->t_op==CON) { - np->nn_offset += ((struct cnode *)tsubtre->tn_tr2)->cn_value; - np->nn_class = OFFS; - np->nn_type = ttree->tn_type; - np->nn_regno = np->nn_nloc; - return((struct tree *)np); +#define locnp ((struct locnnode *)p) + if (tsubtre->tn_tr2->n_op==CON) { + locnp->locnn_offset += ((struct cnode *)tsubtre->tn_tr2)->cn_value; + locnp->locnn_class = OFFS; + locnp->locnn_type = ttree->tn_type; + locnp->locnn_regno = locnp->locnn_nloc; + return((struct node *)locnp); } - if (tsubtre->tn_tr2->t_op==AMPER) { + if (tsubtre->tn_tr2->n_op==AMPER) { #undef tsubtre subtre = ((struct tnode *)((struct tnode *)subtre)->tn_tr2)->tn_tr1; - if (subtre->t_op != NAME) abort(); + if (subtre->n_op != NAME) abort(); #define nsubtre ((struct nnode *)subtre) nsubtre->nn_class += XOFFS-EXTERN; - nsubtre->nn_regno = np->nn_nloc; + nsubtre->nn_regno = locnp->locnn_nloc; nsubtre->nn_type = ttree->tn_type; - return((struct tree *)nsubtre); + return((struct node *)nsubtre); #define tsubtre ((struct tnode *)subtre) #undef nsubtre } #undef tsubtre -#undef np +#undef locnp } - if (subtre->t_op==MINUS && (p = ((struct tnode *)subtre)->tn_tr1)->t_op==NAME && ((struct nnode *)p)->nn_class==REG - && ((struct tnode *)subtre)->tn_tr2->t_op==CON) { + if (subtre->n_op==MINUS && (p = ((struct tnode *)subtre)->tn_tr1)->n_op==NAME && ((struct nnode *)p)->nn_class==REG + && ((struct tnode *)subtre)->tn_tr2->n_op==CON) { #define tsubtre ((struct tnode *)subtre) -#define np ((struct nnode *)p) - np->nn_offset -= ((struct cnode *)tsubtre->tn_tr2)->cn_value; - np->nn_class = OFFS; - np->nn_type = ttree->tn_type; - np->nn_regno = np->nn_nloc; - return((struct tree *)np); +#define locnp ((struct locnnode *)p) + locnp->locnn_offset -= ((struct cnode *)tsubtre->tn_tr2)->cn_value; + locnp->locnn_class = OFFS; + locnp->locnn_type = ttree->tn_type; + locnp->locnn_regno = locnp->locnn_nloc; + return((struct node *)locnp); #undef tsubtre -#undef np +#undef locnp } break; case EXCLA: #undef ttree - if ((opdope1[subtre->t_op]&RELAT)==0) + if ((opdope1[subtre->n_op]&RELAT)==0) break; tree = subtre; - tree->t_op = notrel[tree->t_op-EQUAL]; + tree->n_op = notrel[tree->n_op-EQUAL]; break; #define ttree ((struct tnode *)tree) case COMPL: if (ttree->tn_type==CHAR) ttree->tn_type = INT; - if (subtre->t_op == COMPL) + if (subtre->n_op == COMPL) return(paint(((struct tnode *)subtre)->tn_tr1, ttree->tn_type)); - if (subtre->t_op==CON) { + if (subtre->n_op==CON) { #define csubtre ((struct cnode *)subtre) csubtre->cn_value = ~csubtre->cn_value; - return(paint((struct tree *)csubtre, ttree->tn_type)); + return(paint((struct node *)csubtre, ttree->tn_type)); #undef csubtre } - if (subtre->t_op==LCON) { + if (subtre->n_op==LCON) { #define lsubtre ((struct lnode *)subtre) lsubtre->ln_lvalue = ~lsubtre->ln_lvalue; - return((struct tree *)lsubtre); + return((struct node *)lsubtre); #undef lsubtre } - if (subtre->t_op==ITOL) { + if (subtre->n_op==ITOL) { #define tsubtre ((struct tnode *)subtre) - if (tsubtre->tn_tr1->t_op==CON) { + if (tsubtre->tn_tr1->n_op==CON) { #undef ttree tree = getblk(sizeof(struct lnode)); #define ltree ((struct lnode *)tree) @@ -647,14 +647,14 @@ struct tree *unoptim(tree) register struct tree *tree; { else ltree->ln_lvalue = ~((struct cnode *)tsubtre->tn_tr1)->cn_value; - return((struct tree *)ltree); + return((struct node *)ltree); #define ttree ((struct tnode *)tree) #undef ltree } if (uns(tsubtre->tn_tr1)) break; tsubtre->tn_op = ttree->tn_op; - tsubtre->tn_type = tsubtre->tn_tr1->t_type; + tsubtre->tn_type = tsubtre->tn_tr1->n_type; ttree->tn_op = ITOL; ttree->tn_type = LONG; goto again; @@ -666,21 +666,21 @@ struct tree *unoptim(tree) register struct tree *tree; { case NEG: if (ttree->tn_type==CHAR) ttree->tn_type = INT; - if (subtre->t_op == NEG) + if (subtre->n_op == NEG) return(paint(((struct tnode *)subtre)->tn_tr1, ttree->tn_type)); - if (subtre->t_op==CON) { + if (subtre->n_op==CON) { #define csubtre ((struct cnode *)subtre) csubtre->cn_value = -csubtre->cn_value; - return(paint((struct tree *)csubtre, ttree->tn_type)); + return(paint((struct node *)csubtre, ttree->tn_type)); #undef csubtre } - if (subtre->t_op==LCON) { + if (subtre->n_op==LCON) { #define lsubtre ((struct lnode *)subtre) lsubtre->ln_lvalue = -lsubtre->ln_lvalue; - return((struct tree *)lsubtre); + return((struct node *)lsubtre); #undef lsubtre } - if (subtre->t_op==ITOL && ((struct tnode *)subtre)->tn_tr1->t_op==CON) { + if (subtre->n_op==ITOL && ((struct tnode *)subtre)->tn_tr1->n_op==CON) { #define tsubtre ((struct tnode *)subtre) #undef ttree tree = getblk(sizeof(struct lnode)); @@ -692,7 +692,7 @@ struct tree *unoptim(tree) register struct tree *tree; { ((struct cnode *)tsubtre->tn_tr1)->cn_value; else ltree->ln_lvalue = -((struct cnode *)tsubtre->tn_tr1)->cn_value; - return((struct tree *)ltree); + return((struct node *)ltree); #undef tsubtre #define ttree ((struct tnode *)tree) #undef ltree @@ -700,7 +700,7 @@ struct tree *unoptim(tree) register struct tree *tree; { /* * PDP-11 FP negation */ - if (subtre->t_op==SFCON) { + if (subtre->n_op==SFCON) { #define fsubtre ((struct fnode *)subtre) fsubtre->fn_value ^= 0100000; #ifdef pdp11 @@ -708,27 +708,27 @@ struct tree *unoptim(tree) register struct tree *tree; { #else fsubtre->fn_fvalue = fp_neg(fsubtre->fn_fvalue); #endif - return((struct tree *)fsubtre); + return((struct node *)fsubtre); #undef fsubtre } - if (subtre->t_op==FCON) { + if (subtre->n_op==FCON) { #define fsubtre ((struct fnode *)subtre) #ifdef pdp11 fsubtre->fn_fvalue = -fsubtre->fn_fvalue; #else fsubtre->fn_fvalue = fp_neg(fsubtre->fn_fvalue); #endif - return((struct tree *)fsubtre); + return((struct node *)fsubtre); #undef fsubtre } break; } #undef ttree - if ((opdope1[tree->t_op]&LEAF)==0) + if ((opdope1[tree->n_op]&LEAF)==0) #define ttree ((struct tnode *)tree) ttree->tn_degree = max(islong(ttree->tn_type), degree(subtre)); #undef ttree - return((struct tree *)tree); + return((struct node *)tree); } /* @@ -741,8 +741,8 @@ struct tree *unoptim(tree) register struct tree *tree; { * Pure assignment is handled specially. */ -/* note that t->tn_tr1->t_op == FSEL */ -struct tree *lvfield(t) register struct tnode *t; { +/* note that t->tn_tr1->n_op == FSEL */ +struct node *lvfield(t) register struct tnode *t; { register struct tnode *t1; register struct fasgn *t2; @@ -780,20 +780,20 @@ struct tree *lvfield(t) register struct tnode *t; { /*t=ASANDN(mos,arg)*/ t1->tn_tr1 = t->tn_tr2; /*t1=FSELR(arg,COMMA(flen,bitoffs))*/ - t->tn_tr2 = (struct tree *)t1; + t->tn_tr2 = (struct node *)t1; /*t=ASANDN(mos,FSELR(arg,COMMA(flen,bitoffs)))*/ t1 = (struct tnode *)t1->tn_tr2; /*t1=COMMA(flen,bitoffs)*/ - /*t1 = (struct tree *)tnode(COMMA, INT, (struct tree *)tconst(t1->tn_tr1->cn_value, INT), - (struct tree *)tconst(t1->tn_tr2->cn_value, INT));*/ + /*t1 = (struct node *)tnode(COMMA, INT, (struct node *)tconst(t1->tn_tr1->cn_value, INT), + (struct node *)tconst(t1->tn_tr2->cn_value, INT));*/ /* t1 formerly pointed to a COMMA node holding 2 constants */ /* now it contains its pass 0 value which is the field descriptor */ #define FSt1 ((struct FS *)t1) - return(optim((struct tree *)tnode(FSELT, UNSIGN, (struct tree *)t, (struct tree *)FSt1))); + return(optim((struct node *)tnode(FSELT, UNSIGN, (struct node *)t, (struct node *)FSt1))); #undef FSt1 } error1("Unimplemented field operator"); - return((struct tree *)t); + return((struct node *)t); } #if 0 /* now moved to c1.h */ @@ -802,36 +802,36 @@ struct acl { int nextl; int nextn; struct tnode *nlist[LSTSIZ]; - struct tree *llist[LSTSIZ+1]; + struct node *llist[LSTSIZ+1]; }; #endif /* in reality this can only be called with a struct tnode argument */ -struct tree *acommute(tree) register struct tree *tree; { +struct node *acommute(tree) register struct node *tree; { struct acl acl; int d, i, op, flt, d1, type; - register struct tree *t1, **t2; - struct tree *t; + register struct node *t1, **t2; + struct node *t; #define ttree ((struct tnode *)tree) acl.nextl = 0; acl.nextn = 0; op = ttree->tn_op; type = ttree->tn_type; - flt = isfloat((struct tree *)ttree); - insert(op, (struct tree *)ttree, &acl); + flt = isfloat((struct node *)ttree); + insert(op, (struct node *)ttree, &acl); acl.nextl--; t2 = &acl.llist[acl.nextl]; if (!flt) { /* put constants together */ for (i=acl.nextl; i>0; i--) { - d = t2[-1]->t_type==UNSIGN||t2[0]->t_type==UNSIGN?UNSIGN:INT; - if (t2[0]->t_op==CON && t2[-1]->t_op==CON) { + d = t2[-1]->n_type==UNSIGN||t2[0]->n_type==UNSIGN?UNSIGN:INT; + if (t2[0]->n_op==CON && t2[-1]->n_op==CON) { acl.nextl--; t2--; _const(op, &((struct cnode *)t2[0])->cn_value, ((struct cnode *)t2[1])->cn_value, d); - t2[0]->t_type = d; - } else if (t = (struct tree *)lconst(op, t2[-1], t2[0])) { + t2[0]->n_type = d; + } else if (t = (struct node *)lconst(op, t2[-1], t2[0])) { acl.nextl--; t2--; t2[0] = t; @@ -840,39 +840,39 @@ struct tree *acommute(tree) register struct tree *tree; { } if (op==PLUS || op==OR) { /* toss out "+0" */ - /* isconstant() may return fnode, so need cn_value compatible with fn_value */ - if (acl.nextl>0 && ((t1 = isconstant(*t2)) && ((struct cnode *)t1)->cn_value==0 - || (*t2)->t_op==LCON && ((struct lnode *)*t2)->ln_lvalue==0)) { + /* note: cn_value == 0 means a constant value of 0 (CON) or 0. (SFCON) */ + if (acl.nextl>0 && ((t1 = (struct node *)isconstant(*t2)) && ((struct cnode *)t1)->cn_value==0 + || (*t2)->n_op==LCON && ((struct lnode *)*t2)->ln_lvalue==0)) { acl.nextl--; t2--; } if (acl.nextl <= 0) { - if ((*t2)->t_type==CHAR || (*t2)->t_type==UNCHAR) - *t2 = (struct tree *)tnode(LOAD, ttree->tn_type, *t2, TNULL); - (*t2)->t_type = ttree->tn_type; + if ((*t2)->n_type==CHAR || (*t2)->n_type==UNCHAR) + *t2 = (struct node *)tnode(LOAD, ttree->tn_type, *t2, (struct node *)NULL); + (*t2)->n_type = ttree->tn_type; return(*t2); } /* subsume constant in "&x+c" */ - if (op==PLUS && t2[0]->t_op==CON && t2[-1]->t_op==AMPER) { + if (op==PLUS && t2[0]->n_op==CON && t2[-1]->n_op==AMPER) { t2--; ((struct nnode *)((struct tnode *)t2[0])->tn_tr1)->nn_offset += ((struct cnode *)t2[1])->cn_value; acl.nextl--; } } else if (op==TIMES || op==AND) { t1 = acl.llist[acl.nextl]; - if (t1->t_op==CON) { + if (t1->n_op==CON) { #define ct1 ((struct cnode *)t1) if (ct1->cn_value==0) { for (i=0; icn_value==1 && acl.nextl>0) if (--acl.nextl <= 0) { t1 = acl.llist[0]; - if (uns((struct tree *)ttree)) + if (uns((struct node *)ttree)) paint(t1, ttree->tn_type); return(t1); } @@ -883,13 +883,13 @@ struct tree *acommute(tree) register struct tree *tree; { if (op==PLUS && !flt) distrib(&acl); tree = *(t2 = &acl.llist[0]); - d = max(degree(tree), islong(tree->t_type)); + d = max(degree(tree), islong(tree->n_type)); if (op==TIMES && !flt) { d += regpanic+1; panicposs++; } for (i=0; itn_tr2 = t = *++t2; d1 = degree(t); @@ -898,19 +898,19 @@ struct tree *acommute(tree) register struct tree *tree; { * rt. op of ^ must be in a register. */ if (op==EXOR && dcalc(t, 0)<=12) { - tt1->tn_tr2 = t = optim((struct tree *)tnode(LOAD, t->t_type, t, TNULL)); + tt1->tn_tr2 = t = optim((struct node *)tnode(LOAD, t->n_type, t, (struct node *)NULL)); /* in this case optim() is guaranteed to return a struct tnode */ - if (opdope1[t->t_op] & LEAF) abort(); + if (opdope1[t->n_op] & LEAF) abort(); d1 = ((struct tnode *)t)->tn_degree; } tt1->tn_degree = d = d==d1? d+islong(tt1->tn_type): max(d, d1); tt1->tn_tr1 = tree; - tree = (struct tree *)tt1; - if (tree->t_type==LONG || tree->t_type==UNLONG) { - if (tree->t_op==TIMES) + tree = (struct node *)tt1; + if (tree->n_type==LONG || tree->n_type==UNLONG) { + if (tree->n_op==TIMES) tree = hardlongs(tree); /* assume isconstant() returns cnode (CON) not fnode (SFCON) since long */ - else if (tree->t_op==PLUS && (t = isconstant(((struct tnode *)tree)->tn_tr1)) + else if (tree->n_op==PLUS && (t = (struct node *)isconstant(((struct tnode *)tree)->tn_tr1)) && ((struct cnode *)t)->cn_value < 0 && !uns(t)) { #define ttree ((struct tnode *)tree) ttree->tn_op = MINUS; @@ -923,7 +923,7 @@ struct tree *acommute(tree) register struct tree *tree; { } #undef tt1 } - if (tree->t_op==TIMES && ispow2((struct tnode *)tree)) + if (tree->n_op==TIMES && ispow2((struct tnode *)tree)) #define ttree ((struct tnode *)tree) ttree->tn_degree = max(degree(ttree->tn_tr1), islong(ttree->tn_type)); #undef ttree @@ -931,14 +931,14 @@ struct tree *acommute(tree) register struct tree *tree; { return(tree); } -int sideeffects(tp) register struct tree *tp; { +int sideeffects(tp) register struct node *tp; { register int dope; if (tp==NULL) return(0); - dope = opdope1[tp->t_op]; + dope = opdope1[tp->n_op]; if (dope&LEAF) { - if (tp->t_op==AUTOI || tp->t_op==AUTOD) + if (tp->n_op==AUTOI || tp->n_op==AUTOD) return(1); return(0); } @@ -967,27 +967,27 @@ void distrib(list) struct acl *list; { * fewest divisors. Reduce this pair to c1*(y+c2*x) * and iterate until no reductions occur. */ - register struct tree **p1, **p2; - struct tree *t; + register struct node **p1, **p2; + struct node *t; int ndmaj, ndmin; - struct tree **dividend, **divisor; - struct tree **maxnod, **mindiv; + struct node **dividend, **divisor; + struct node **maxnod, **mindiv; loop: maxnod = &list->llist[list->nextl]; ndmaj = 1000; dividend = 0; for (p1 = list->llist; p1 <= maxnod; p1++) { - if ((*p1)->t_op!=TIMES || ((struct tnode *)*p1)->tn_tr2->t_op!=CON) + if ((*p1)->n_op!=TIMES || ((struct tnode *)*p1)->tn_tr2->n_op!=CON) continue; ndmin = 0; for (p2 = list->llist; p2 <= maxnod; p2++) { - if (p1==p2 || (*p2)->t_op!=TIMES || ((struct tnode *)*p2)->tn_tr2->t_op!=CON) + if (p1==p2 || (*p2)->n_op!=TIMES || ((struct tnode *)*p2)->tn_tr2->n_op!=CON) continue; if (((struct cnode *)((struct tnode *)*p1)->tn_tr2)->cn_value == ((struct cnode *)((struct tnode *)*p2)->tn_tr2)->cn_value) { ((struct tnode *)*p2)->tn_tr2 = ((struct tnode *)*p1)->tn_tr1; ((struct tnode *)*p2)->tn_op = PLUS; - ((struct tnode *)*p1)->tn_tr1 = (struct tree *)((struct tnode *)*p2); + ((struct tnode *)*p1)->tn_tr1 = (struct node *)((struct tnode *)*p2); *p1 = optim(*p1); squash(p2, maxnod); list->nextl--; @@ -1016,10 +1016,10 @@ void distrib(list) struct acl *list; { p2 = divisor; tt->tn_op = PLUS; tt->tn_type = ((struct tnode *)*p1)->tn_type; - tt->tn_tr1 = (struct tree *)((struct tnode *)*p1); + tt->tn_tr1 = (struct node *)((struct tnode *)*p1); tt->tn_tr2 = ((struct tnode *)*p2)->tn_tr1; ((struct cnode *)((struct tnode *)*p1)->tn_tr2)->cn_value /= ((struct cnode *)((struct tnode *)*p2)->tn_tr2)->cn_value; - ((struct tnode *)*p2)->tn_tr1 = (struct tree *)tt; + ((struct tnode *)*p2)->tn_tr1 = (struct node *)tt; #undef tt t = optim(*p2); if (p1 < p2) { @@ -1033,8 +1033,8 @@ void distrib(list) struct acl *list; { goto loop; } -void squash(p, maxp) struct tree **p; struct tree **maxp; { - register struct tree **np; +void squash(p, maxp) struct node **p; struct node **maxp; { + register struct node **np; for (np = p; np < maxp; np++) *np = *(np+1); @@ -1137,25 +1137,25 @@ void _const(op, vp, v, type) int op; register _INT *vp; register _INT v; int typ error1("C error: const"); } -struct lnode *lconst(op, lp, rp) int op; register struct tree *lp; register struct tree *rp; { +struct lnode *lconst(op, lp, rp) int op; register struct node *lp; register struct node *rp; { _UNSIGNED_LONG l, r; - if (lp->t_op==LCON) + if (lp->n_op==LCON) l = ((struct lnode *)lp)->ln_lvalue; - else if (lp->t_op==ITOL && ((struct tnode *)lp)->tn_tr1->t_op==CON) { + else if (lp->n_op==ITOL && ((struct tnode *)lp)->tn_tr1->n_op==CON) { #define tlp ((struct tnode *)lp) - if (tlp->tn_tr1->t_type==INT) + if (tlp->tn_tr1->n_type==INT) l = ((struct cnode *)tlp->tn_tr1)->cn_value; else l = (_UNSIGNED_INT)((struct cnode *)tlp->tn_tr1)->cn_value; #undef tlp } else return(0); - if (rp->t_op==LCON) + if (rp->n_op==LCON) r = ((struct lnode *)rp)->ln_lvalue; - else if (rp->t_op==ITOL && ((struct tnode *)rp)->tn_tr1->t_op==CON) { + else if (rp->n_op==ITOL && ((struct tnode *)rp)->tn_tr1->n_op==CON) { #define trp ((struct tnode *)rp) - if (trp->tn_tr1->t_type==INT) + if (trp->tn_tr1->n_type==INT) r = ((struct cnode *)trp->tn_tr1)->cn_value; else r = (_UNSIGNED_INT)((struct cnode *)trp->tn_tr1)->cn_value; @@ -1220,7 +1220,7 @@ struct lnode *lconst(op, lp, rp) int op; register struct tree *lp; register stru default: return(0); } - if (lp->t_op==LCON) { + if (lp->n_op==LCON) { #define llp ((struct lnode *)lp) llp->ln_lvalue = l; return(llp); @@ -1235,15 +1235,15 @@ struct lnode *lconst(op, lp, rp) int op; register struct tree *lp; register stru #undef llp } -void insert(op, tree, list) int op; register struct tree *tree; register struct acl *list; { +void insert(op, tree, list) int op; register struct node *tree; register struct acl *list; { register int d; int d1, i; - struct tree *t; + struct node *t; ins: - if (tree->t_op != op) + if (tree->n_op != op) tree = optim(tree); - if (tree->t_op == op && list->nextn < LSTSIZ-2) { + if (tree->n_op == op && list->nextn < LSTSIZ-2) { #define ttree ((struct tnode *)tree) list->nlist[list->nextn++] = ttree; insert(op, ttree->tn_tr1, list); @@ -1253,9 +1253,9 @@ ins: } if (!isfloat(tree)) { /* c1*(x+c2) -> c1*x+c1*c2 */ - if ((tree->t_op==TIMES||tree->t_op==LSHIFT) - && ((struct tnode *)tree)->tn_tr2->t_op==CON && ((struct cnode *)((struct tnode *)tree)->tn_tr2)->cn_value>0 - && ((struct tnode *)tree)->tn_tr1->t_op==PLUS && ((struct tnode *)((struct tnode *)tree)->tn_tr1)->tn_tr2->t_op==CON) { + if ((tree->n_op==TIMES||tree->n_op==LSHIFT) + && ((struct tnode *)tree)->tn_tr2->n_op==CON && ((struct cnode *)((struct tnode *)tree)->tn_tr2)->cn_value>0 + && ((struct tnode *)tree)->tn_tr1->n_op==PLUS && ((struct tnode *)((struct tnode *)tree)->tn_tr1)->tn_tr2->n_op==CON) { #define ttree ((struct tnode *)tree) d = ((struct cnode *)ttree->tn_tr2)->cn_value; if (ttree->tn_op==TIMES) @@ -1283,7 +1283,7 @@ ins: list->llist[list->nextl++] = tree; } -struct tnode *tnode(op, type, tr1, tr2) int op; int type; struct tree *tr1; struct tree *tr2; { +struct tnode *tnode(op, type, tr1, tr2) int op; int type; struct node *tr1; struct node *tr2; { register struct tnode *p; p = (struct tnode *)getblk(sizeof(struct tnode)); @@ -1309,15 +1309,15 @@ struct cnode *tconst(val, type) int val; int type; { return(p); } -struct tree *getblk(size) int size; { +struct node *getblk(size) int size; { #if 1 - return (struct tree *)Tblock(size); + return (struct node *)Tblock(size); #else - register struct tree *p; + register struct node *p; if (size&01) size++; - p = (struct tree *)curbase; + p = (struct node *)curbase; if ((curbase += size) >= coremax) { #ifdef pdp11 if (sbrk(1024) == (char *)-1) { @@ -1339,16 +1339,17 @@ int islong(t) int t; { return(1); } -struct tree *isconstant(t) register struct tree *t; { - if (t->t_op==CON || t->t_op==SFCON) - return(t); - if (t->t_op==ITOL && ((struct tnode *)t)->tn_tr1->t_op==CON) - return(((struct tnode *)t)->tn_tr1); +/* returns a struct cnode, may be a struct fnode containing struct cnode */ +struct cnode *isconstant(t) register struct node *t; { + if (t->n_op==CON || t->n_op==SFCON) + return((struct cnode *)t); + if (t->n_op==ITOL && ((struct tnode *)t)->tn_tr1->n_op==CON) + return((struct cnode *)((struct tnode *)t)->tn_tr1); return(NULL); } -struct tree *hardlongs(t) register struct tree *t; { - switch(t->t_op) { +struct node *hardlongs(t) register struct node *t; { + switch(t->n_op) { case TIMES: case DIVIDE: @@ -1369,7 +1370,7 @@ struct tree *hardlongs(t) register struct tree *t; { tt->tn_op += ULASTIMES-ASTIMES; else tt->tn_op += LASTIMES-ASTIMES; - tt->tn_tr1 = (struct tree *)tnode(AMPER, LONG+PTR, tt->tn_tr1, TNULL); + tt->tn_tr1 = (struct node *)tnode(AMPER, LONG+PTR, tt->tn_tr1, (struct node *)NULL); break; #undef tt @@ -1382,10 +1383,10 @@ struct tree *hardlongs(t) register struct tree *t; { /* * Is tree of unsigned type? */ -int uns(tp) struct tree *tp; { +int uns(tp) struct node *tp; { register int t; - t = tp->t_type; + t = tp->n_type; if (t==UNSIGN || t==UNCHAR || t==UNLONG || t&XTYPE) return(1); return(0); diff --git a/ccom.h b/ccom.h index d9f1246..99e9b2b 100644 --- a/ccom.h +++ b/ccom.h @@ -23,13 +23,12 @@ typedef struct { uint32_t l; uint32_t h; } _DOUBLE; #ifndef NULL #define NULL 0 #endif -#define TNULL (struct tree *)NULL /* * Structure of namelist */ struct nmlist { - /* note: this must be compatible with struct tree in respect of the */ + /* note: this must be compatible with struct node in respect of the */ /* htype and hsubsp fields, because of length(), rlength() computations */ char hclass; /* storage class */ char hflag; /* various flags */ @@ -73,65 +72,90 @@ struct tdim { /* * Tree node for unary and binary */ -struct tree { - int t_op; - int t_type; - int *t_subsp; /* subscript list for arrays; pass 0 only */ - union str *t_strp; /* structure descr for structs; pass 0 only */ +struct node { + int n_op; + int n_type; + int *n_subsp; /* subscript list for arrays; pass 0 only */ + union str *n_strp; /* structure descr for structs; pass 0 only */ }; struct tnode { - struct tree tn_tree; -#define tn_op tn_tree.t_op -#define tn_type tn_tree.t_type -#define tn_subsp tn_tree.t_subsp -#define tn_strp tn_tree.t_strp - struct tree *tn_tr1; - struct tree *tn_tr2; + struct node tn_node; +#define tn_op tn_node.n_op +#define tn_type tn_node.n_type +#define tn_subsp tn_node.n_subsp +#define tn_strp tn_node.n_strp + struct node *tn_tr1; + struct node *tn_tr2; int tn_degree; /* pass 1 only */ }; /* - * tree names for locals + * node names */ struct nnode { - struct tree nn_tree; -#define nn_op nn_tree.t_op -#define nn_type nn_tree.t_type -#define nn_subsp nn_tree.t_subsp -#define nn_strp nn_tree.t_strp - struct nmlist *nn_tr1; /* pass 0 only */ + struct node nn_node; +#define nn_op nn_node.n_op +#define nn_type nn_node.n_type +#define nn_subsp nn_node.n_subsp +#define nn_strp nn_node.n_strp + struct nmlist *nn_nmlist; /* pass 0 only */ char nn_class; /* pass 1 only */ char nn_regno; /* pass 1 only */ int nn_offset; /* pass 1 only */ - int nn_nloc; /* pass 1 only */ }; /* - * tree names for externals + * node names for locals + * + * locnn_class can be: + * SOFFS: %offset+L%nloc(r%regno) + * OFFS: %offset(r%regno) XXX this does not use nloc + * STATIC: %offset+L%nloc + * REG: r%nloc */ -struct xnode { - struct tree xn_tree; -#define xn_op xn_tree.t_op -#define xn_type xn_tree.t_type -#define xn_subsp xn_tree.t_subsp -#define xn_strp xn_tree.t_strp - struct nmlist *xn_tr1; /* pass 0 only */ - char xn_class; /* pass 1 only */ - char xn_regno; /* pass 1 only */ - int xn_offset; /* pass 1 only */ - char *xn_name; /* pass 1 only */ +struct locnnode { + struct nnode locnn_nnode; +#define locnn_op locnn_nnode.nn_op +#define locnn_type locnn_nnode.nn_type +#define locnn_subsp locnn_nnode.nn_subsp +#define locnn_strp locnn_nnode.nn_strp +#define locnn_nmlist locnn_nnode.nn_nmlist +#define locnn_class locnn_nnode.nn_class +#define locnn_regno locnn_nnode.nn_regno +#define locnn_offset locnn_nnode.nn_offset + int locnn_nloc; /* pass 1 only */ +}; + +/* + * node names for externals + * + * extnn_class can be: + * XOFFS: %offset+%name(r%regno) + * EXTERN: %offset+%name + */ +struct extnnode { + struct nnode extnn_nnode; +#define extnn_op extnn_nnode.nn_op +#define extnn_type extnn_nnode.nn_type +#define extnn_subsp extnn_nnode.nn_subsp +#define extnn_strp extnn_nnode.nn_strp +#define extnn_nmlist extnn_nnode.nn_nmlist +#define extnn_class extnn_nnode.nn_class +#define extnn_regno extnn_nnode.nn_regno +#define extnn_offset extnn_nnode.nn_offset + char *extnn_name; /* pass 1 only */ }; /* * short constants */ struct cnode { - struct tree cn_tree; -#define cn_op cn_tree.t_op -#define cn_type cn_tree.t_type -#define cn_subsp cn_tree.t_subsp -#define cn_strp cn_tree.t_strp + struct node cn_node; +#define cn_op cn_node.n_op +#define cn_type cn_node.n_type +#define cn_subsp cn_node.n_subsp +#define cn_strp cn_node.n_strp _INT cn_value; }; @@ -139,11 +163,11 @@ struct cnode { * long constants */ struct lnode { - struct tree ln_tree; -#define ln_op ln_tree.t_op -#define ln_type ln_tree.t_type -#define ln_subsp ln_tree.t_subsp -#define ln_strp ln_tree.t_strp + struct node ln_node; +#define ln_op ln_node.n_op +#define ln_type ln_node.n_type +#define ln_subsp ln_node.n_subsp +#define ln_strp ln_node.n_strp _LONG ln_lvalue; }; @@ -151,12 +175,12 @@ struct lnode { * Floating constants */ struct fnode { - struct tree fn_tree; -#define fn_op fn_tree.t_op -#define fn_type fn_tree.t_type -#define fn_subsp fn_tree.t_subsp -#define fn_strp fn_tree.t_strp - int fn_value; + struct cnode fn_cnode; +#define fn_op fn_cnode.cn_op +#define fn_type fn_cnode.cn_type +#define fn_subsp fn_cnode.cn_subsp +#define fn_strp fn_cnode.cn_strp +#define fn_value fn_cnode.cn_value _DOUBLE fn_fvalue; }; @@ -164,14 +188,14 @@ struct fnode { * Node used for field assignments */ struct fasgn { - struct tree fa_tree; -#define fa_op fa_tree.t_op -#define fa_type fa_tree.t_type -#define fa_subsp fa_tree.t_subsp -#define fa_strp fa_tree.t_strp - struct tree *fa_tr1; - struct tree *fa_tr2; - int fa_degree; /* pass 1 only */ + struct tnode fa_tnode; +#define fa_op fa_tnode.tn_op +#define fa_type fa_tnode.tn_type +#define fa_subsp fa_tnode.tn_subsp +#define fa_strp fa_tnode.tn_strp +#define fa_tr1 fa_tnode.tn_tr1 +#define fa_tr2 fa_tnode.tn_tr2 +#define fa_degree fa_tnode.tn_degree int fa_mask; /* pass 1 only */ }; diff --git a/fields.sed b/fields.sed index 58966ae..5bf36b7 100644 --- a/fields.sed +++ b/fields.sed @@ -4,7 +4,10 @@ s/$/@/ s/[^A-Za-z0-9_]\+/@&@/g # types -s/@union\(@[ ]*@tree\)@/@struct\1@/g +s/@union\(@[ ]*@\)tree@/@struct\1node@/g + +# values +s/@TNULL@/@(struct node *)NULL@/g # tnode s/@t@\.@op@/@tn_op@/g @@ -20,7 +23,7 @@ s/@n@\.@op@/@nn_op@/g s/@n@\.@type@/@nn_type@/g s/@n@\.@subsp@/@nn_subsp@/g s/@n@\.@strp@/@nn_strp@/g -s/@n@\.@tr1@/@nn_tr1@/g +s/@n@\.@tr1@/@nn_nmlist@/g s/@n@\.@class@/@nn_class@/g s/@n@\.@regno@/@nn_regno@/g s/@n@\.@offset@/@nn_offset@/g -- 2.34.1