struct nmlist P;
};
-/*
- * Structure of tree0 nodes for operators
- */
-struct tnode0 {
- int op; /* operator */
- int type; /* data type */
- int *subsp; /* subscript list (for arrays) */
- union str *strp; /* structure description for structs */
- union tree0 *tr1; /* left operand */
- union tree0 *tr2; /* right operand */
-};
-
-/*
- * Tree node for constants
- */
-struct tconst0 {
- int op;
- int type;
- int *subsp;
- union str *strp;
- _INT value;
-};
-
-/*
- * Tree node for long constants
- */
-struct lconst0 {
- int op;
- int type;
- int *subsp;
- union str *strp;
- _LONG lvalue;
-};
-
-/*
- * tree0 node for floating
- * constants
- */
-struct ftconst0 {
- int op;
- int type;
- int *subsp;
- union str *strp;
- char *cstr;
-};
-
-/*
- * All possibilities for tree0 nodes
- */
-union tree0 {
- struct tnode0 t;
- struct tconst0 c;
- struct lconst0 l;
- struct ftconst0 f;
- /* struct nmlist n;*/
- /* n occurs as tr1 of a NAME node, points into symbol table */
- /* we will just cast tr1 to "struct nmlist *" in that particular case */
- /* struct FS fld;*/
- /* fld occurs as tr2 of an FSEL node, points into structure description */
- /* we will just cast tr2 to "struct FS *" in that particular case */
-};
-
-
/*
* Place used to keep dimensions
* during declarations
int dimens[5];
};
-#define TNULL0 (union tree0 *)NULL
-
extern char cvtab[4][4];
extern char filename[MAXPATHLEN]; /* Nick */
extern int opdope0[];
extern char symbuf[MAXCPS+2];
extern struct nmlist *hshtab[HSHSIZ];
extern int kwhash[(HSHSIZ+LNBPW-1)/LNBPW];
-extern union tree0 **cp0;
+extern union tree **cp0;
extern int isn0;
extern struct swtab swtab[SWSIZ];
extern int unscflg;
#endif
extern int regvar;
extern int bitoffs;
-extern struct tnode0 funcblk0;
+extern struct tnode funcblk0;
extern char cvntab[];
extern char numbuf[64];
extern struct nmlist **memlist;
void cntstr __P((void));
int getcc __P((void));
int mapch __P((int ac));
-union tree0 *tree0 __P((/*int eflag*/));
-union tree0 *xprtype0 __P((void));
+union tree *tree0 __P((/*int eflag*/));
+union tree *xprtype0 __P((void));
char *copnum __P((int len));
/* c01.c */
void build __P((int op));
-void structident __P((register union tree0 *p1, register union tree0 *p2));
-union tree0 *convert __P((union tree0 *p, int t, int cvn, int len));
-void setype __P((register union tree0 *p, register int t, register union tree0 *newp));
-union tree0 *chkfun __P((register union tree0 *p));
-union tree0 *disarray __P((register union tree0 *p));
-void chkw __P((union tree0 *p, int okt));
+void structident __P((register union tree *p1, register union tree *p2));
+union tree *convert __P((union tree *p, int t, int cvn, int len));
+void setype __P((register union tree *p, register int t, register union tree *newp));
+union tree *chkfun __P((register union tree *p));
+union tree *disarray __P((register union tree *p));
+void chkw __P((union tree *p, int okt));
int lintyp __P((int t));
void werror0 __P((char *s, ...));
void error0 __P((char *s, ...));
-union tree0 *block __P((int op, int t, int *subs, union str *str, union tree0 *p1, union tree0 *p2));
-union tree0 *nblock __P((register struct nmlist *ds));
-union tree0 *cblock __P((int v));
-union tree0 *fblock __P((int t, char *string));
+union tree *block __P((int op, int t, int *subs, union str *str, union tree *p1, union tree *p2));
+union tree *nblock __P((register struct nmlist *ds));
+union tree *cblock __P((int v));
+union tree *fblock __P((int t, char *string));
char *Tblock __P((int n));
char *starttree __P((void));
void endtree __P((char *tp));
char *Dblock __P((int n));
-void chklval __P((register union tree0 *p));
-int fold __P((int op, register union tree0 *p1, union tree0 *p2));
+void chklval __P((register union tree *p));
+int fold __P((int op, register union tree *p1, union tree *p2));
int conexp __P((void));
-void assignop __P((int op, register union tree0 *p1, register union tree0 *p2));
+void assignop __P((int op, register union tree *p1, register union tree *p2));
struct nmlist *gentemp __P((int type));
/* c02.c */
void setinit __P((register struct nmlist *np));
void statement __P((void));
int forstmt __P((void));
-union tree0 *pexpr __P((/*int eflag*/));
+union tree *pexpr __P((/*int eflag*/));
void pswitch0 __P((void));
void funchead __P((void));
void blockhead __P((void));
/* c04.c */
int decref0 __P((register int t));
int incref0 __P((register int t));
-void cbranch0 __P((union tree0 *t, int lbl, int cond));
-void rcexpr0 __P((register union tree0 *tp));
-void treeout __P((register union tree0 *tp, int isstruct));
+void cbranch0 __P((union tree *t, int lbl, int cond));
+void rcexpr0 __P((register union tree *tp));
+void treeout __P((register union tree *tp, int isstruct));
void branch0 __P((int lab));
void label0 __P((int l));
-int plength __P((register union tree0 *p));
-int length __P((union tree0 *cs));
-int rlength __P((union tree0 *cs));
+int plength __P((register union tree *p));
+int length __P((union tree *cs));
+int rlength __P((union tree *cs));
int simplegoto __P((void));
int nextchar __P((void));
int spnextchar __P((void));
int isn0 = 1;
int peeksym = -1;
int line = 1;
-struct tnode0 funcblk0 = { NAME };
+struct tnode funcblk0 = { NAME };
struct kwtab kwtab[] = {
{"int", INT},
{0, 0}
};
-union tree0 *cmst[CMSIZ];
-union tree0 **cp0 = cmst;
+union tree *cmst[CMSIZ];
+union tree **cp0 = cmst;
int Wflag; /* print warning messages */
#if 0
* "," or ":" because those delimiters are special
* in initializer (and some other) expressions.
*/
-union tree0 *tree0(/*eflag*/) /*int eflag;*/ {
+union tree *tree0(/*eflag*/) /*int eflag;*/ {
int *op, opst[SSIZE], *pp, prst[SSIZE];
register int andflg, o;
register struct nmlist *cs;
int p, ps, os, xo = 0, *xop;
/*char *svtree;*/
- static struct tconst0 garbage = { CON, INT, (int *)NULL, (union str *)NULL, 0 };
+ static struct tconst garbage = { CON, INT, (int *)NULL, (union str *)NULL, 0 };
/*svtree = starttree();*/
op = opst;
goto tand;
case LCON:
- *cp0 = (union tree0 *)Tblock(sizeof(struct lconst0));
+ *cp0 = (union tree *)Tblock(sizeof(struct lconst));
(*cp0)->l.op = LCON;
(*cp0)->l.type = LONG;
(*cp0)->l.lvalue = lcval;
cs->hclass = STATIC;
cs->hoffset = cval;
*cp0++ = block(NAME, unscflg? ARRAY+UNCHAR:ARRAY+CHAR, &nchstr,
- (union str *)NULL, (union tree0 *)cs, TNULL0);
+ (union str *)NULL, (union tree *)cs, TNULL);
tand:
if(cp0>=cmst+CMSIZ) {
case MCALL:
*cp0++ = block(NULLOP0, INT, (int *)NULL,
- (union str *)NULL, TNULL0, TNULL0);
+ (union str *)NULL, TNULL, TNULL);
os = CALL;
break;
errflush(o);
/*if (eflag)
endtree(svtree);*/
- return((union tree0 *) &garbage);
+ return((union tree *) &garbage);
}
-union tree0 *xprtype0() {
+union tree *xprtype0() {
struct nmlist typer, absname;
int sc;
- register union tree0 **scp;
+ register union tree **scp;
scp = cp0;
sc = DEFXTRN; /* will cause error0 if class mentioned */
decl1(sc, &typer, 0, &absname);
cp0 = scp;
return(block(ETYPE, absname.htype, absname.hsubsp,
- absname.hstrp, TNULL0, TNULL0));
+ absname.hstrp, TNULL, TNULL));
}
char *copnum(len) int len; {
void build(op) int op; {
register int t1;
int t2, t;
- register union tree0 *p1, *p2, *p3;
+ register union tree *p1, *p2, *p3;
int dope, leftc, cvn, pcvn;
/*
error0("Disallowed conversion");
if (p1->t.type==UNCHAR) {
*cp0++ = block(ETYPE, UNSIGN, (int *)NULL, (union str *)NULL,
- TNULL0, TNULL0);
+ TNULL, TNULL);
*cp0++ = p2;
build(CAST);
*cp0++ = cblock(0377);
case STAR:
if ((t1&XTYPE) == FUNC)
error0("Illegal indirection");
- *cp0++ = block(STAR, decref0(t1), p1->t.subsp, p1->t.strp, p1, TNULL0);
+ *cp0++ = block(STAR, decref0(t1), p1->t.subsp, p1->t.strp, p1, TNULL);
return;
case AMPER:
if (p1->t.op==NAME || p1->t.op==STAR) {
- *cp0++ = block(op,incref0(p1->t.type),p1->t.subsp,p1->t.strp,p1,TNULL0);
+ *cp0++ = block(op,incref0(p1->t.type),p1->t.subsp,p1->t.strp,p1,TNULL);
return;
}
error0("Illegal lvalue");
if (((struct nmlist *)p2->t.tr1)->hflag&FFIELD)
#if 1
cp0[-1] = block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL,
- cp0[-1], (union tree0 *)((struct nmlist *)p2->t.tr1)->hstrp);
+ cp0[-1], (union tree *)((struct nmlist *)p2->t.tr1)->hstrp);
#else
*cp0++ = block(FSEL, UNSIGN, (int *)NULL, (union str *)NULL,
- *--cp0, (union tree0 *)((struct nmlist *)p2->t.tr1)->hstrp);
+ *--cp0, (union tree *)((struct nmlist *)p2->t.tr1)->hstrp);
#endif
return;
}
t1 = DOUBLE;
else if (op==FTOI)
t1 = INT;
- if (!fold(op, p1, (union tree0 *)NULL))
- *cp0++ = block(op, t1, p1->t.subsp, p1->t.strp, p1,TNULL0);
+ if (!fold(op, p1, (union tree *)NULL))
+ *cp0++ = block(op, t1, p1->t.subsp, p1->t.strp, p1,TNULL);
return;
}
cvn = 0;
cvn = 0;
if (op==MINUS) {
pcvn++;
- p1 = block(ITOL, LONG, (int *)NULL, (union str *)NULL, p1, TNULL0);
- p2 = block(ITOL, LONG, (int *)NULL, (union str *)NULL, p2, TNULL0);
+ p1 = block(ITOL, LONG, (int *)NULL, (union str *)NULL, p1, TNULL);
+ p2 = block(ITOL, LONG, (int *)NULL, (union str *)NULL, p2, TNULL);
t = LONG;
} else {
if (t1!=t2 || (t1!=(PTR+CHAR) && t1!=(PTR+UNCHAR)))
p2->t.strp = p1->t.strp;
}
if (t==INT && p1->t.type==CHAR)
- p2 = block(ITOC, INT, (int *)NULL, (union str *)NULL, p2, TNULL0);
+ p2 = block(ITOC, INT, (int *)NULL, (union str *)NULL, p2, TNULL);
*cp0++ = p2;
return;
}
}
}
-void structident(p1, p2) register union tree0 *p1; register union tree0 *p2; {
+void structident(p1, p2) register union tree *p1; register union tree *p2; {
register struct nmlist *np, *nporig;
int vartypes = 0, namesame = 1;
p2->t.type = np->htype;
p2->t.strp = np->hstrp;
p2->t.subsp = np->hsubsp;
- p2->t.tr1 = (union tree0 *)np;
+ p2->t.tr1 = (union tree *)np;
return;
}
np = np->nextnm;
/*
* Generate the appropriate conversion operator.
*/
-union tree0 *convert(p, t, cvn, len) union tree0 *p; int t; int cvn; int len; {
+union tree *convert(p, t, cvn, len) union tree *p; int t; int cvn; int len; {
register int op;
if (cvn==0)
error0("Illegal conversion");
return(block(op, t, (int *)NULL, (union str *)NULL, p, cblock(len)));
}
- return(block(op, t, (int *)NULL, (union str *)NULL, p, TNULL0));
+ return(block(op, t, (int *)NULL, (union str *)NULL, p, TNULL));
}
/*
* type at.
* Used with structure references.
*/
-void setype(p, t, newp) register union tree0 *p; register int t; register union tree0 *newp; {
+void setype(p, t, newp) register union tree *p; register int t; register union tree *newp; {
for (;; p = p->t.tr1) {
p->t.subsp = newp->t.subsp;
p->t.strp = newp->t.strp;
* A mention of a function name is turned into
* a pointer to that function.
*/
-union tree0 *chkfun(p) register union tree0 *p; {
+union tree *chkfun(p) register union tree *p; {
register int t;
if (((t = p->t.type)&XTYPE)==FUNC && p->t.op!=ETYPE)
- return(block(AMPER,incref0(t),p->t.subsp,p->t.strp,p,TNULL0));
+ return(block(AMPER,incref0(t),p->t.subsp,p->t.strp,p,TNULL));
return(p);
}
* A mention of an array is turned into
* a pointer to the base of the array.
*/
-union tree0 *disarray(p) register union tree0 *p; {
+union tree *disarray(p) register union tree *p; {
register int t;
if (p==NULL)
* okt might be nonexistent or 'long'
* (e.g. for <<).
*/
-void chkw(p, okt) union tree0 *p; int okt; {
+void chkw(p, okt) union tree *p; int okt; {
register int t = p->t.type;
if (t == UNLONG)
* setting the operator, type, dimen/struct table ptrs,
* and the operands.
*/
-union tree0 *block(op, t, subs, str, p1,p2) int op; int t; int *subs; union str *str; union tree0 *p1; union tree0 *p2; {
- register union tree0 *p;
+union tree *block(op, t, subs, str, p1,p2) int op; int t; int *subs; union str *str; union tree *p1; union tree *p2; {
+ register union tree *p;
/*fprintf(stderr, "block(%d, %d, {%d, %d}, {%d, %d})\n", op, t,
(op == NAME) ? -2 : (p1 ? (int)(_INT)p1->t.op : -1),
(op == NAME) ? -2 : (p1 ? (int)(_INT)p1->t.type : -1),
(op == FSEL) ? -3 : (p2 ? (int)(_INT)p2->t.op : -1),
(op == FSEL) ? -3 : (p2 ? (int)(_INT)p2->t.type : -1));*/
- p = (union tree0 *)Tblock(sizeof(struct tnode0));
+ p = (union tree *)Tblock(sizeof(struct tnode));
p->t.op = op;
p->t.type = t;
p->t.subsp = subs;
return(p);
}
-union tree0 *nblock(ds) register struct nmlist *ds; {
- return(block(NAME, ds->htype, ds->hsubsp, ds->hstrp, (union tree0 *)ds, TNULL0));
+union tree *nblock(ds) register struct nmlist *ds; {
+ return(block(NAME, ds->htype, ds->hsubsp, ds->hstrp, (union tree *)ds, TNULL));
}
/*
* Generate a block for a constant
*/
-union tree0 *cblock(v) int v; {
- register union tree0 *p;
+union tree *cblock(v) int v; {
+ register union tree *p;
/*fprintf(stderr, "cblock(0%06o)\n", v & 0177777);*/
- p = (union tree0 *)Tblock(sizeof(struct tconst0));
+ p = (union tree *)Tblock(sizeof(struct tconst));
p->c.op = CON;
p->c.type = INT;
p->c.subsp = NULL;
/*
* A block for a float constant
*/
-union tree0 *fblock(t, string) int t; char *string; {
- register union tree0 *p;
+union tree *fblock(t, string) int t; char *string; {
+ register union tree *p;
/*fprintf(stderr, "fblock(%d, \"%s\")\n", t, string);*/
- p = (union tree0 *)Tblock(sizeof(struct ftconst0));
+ p = (union tree *)Tblock(sizeof(struct ftconst));
p->f.op = FCON;
p->f.type = t;
p->f.subsp = NULL;
/*
* Check that a tree0 can be used as an lvalue.
*/
-void chklval(p) register union tree0 *p; {
+void chklval(p) register union tree *p; {
if (p->t.op==FSEL)
p = p->t.tr1;
if (p->t.op!=NAME && p->t.op!=STAR)
* but this is used to allow constant expressions
* to be used in switches and array bounds.
*/
-int fold(op, p1, p2) int op; register union tree0 *p1; union tree0 *p2; {
+int fold(op, p1, p2) int op; register union tree *p1; union tree *p2; {
register int v1, v2;
int unsignf;
* for example an array bound or a case value.
*/
int conexp() {
- register union tree0 *t;
+ register union tree *t;
char *st = starttree();
initflg++;
if (t = tree0(/*1*/))
/*
* Handle peculiar assignment ops that need a temporary.
*/
-void assignop(op, p1, p2) int op; register union tree0 *p1; register union tree0 *p2; {
+void assignop(op, p1, p2) int op; register union tree *p1; register union tree *p2; {
register struct nmlist *np;
op += PLUS - ASPLUS;
tp->hsubsp = NULL;
tp->hstrp = NULL;
tp->hblklev = blklev;
- autolen -= rlength((union tree0 *)tp);
+ autolen -= rlength((union tree *)tp);
tp->hoffset = autolen;
if (autolen < maxauto)
maxauto = autolen;
error0("Inappropriate parameters");
} else if ((o=symbol())==COMMA || o==SEMI) {
peeksym = o;
- o = (length((union tree0 *)ds)+ALIGN) & ~ALIGN;
+ o = (length((union tree *)ds)+ALIGN) & ~ALIGN;
if (sclass==STATIC) {
setinit(ds);
outcode("BSBBSBN", SYMDEF, "", BSS, NLABEL, ds->name, SSPACE, o);
struct nmlist np;
register int nel, ninit;
int width, isarray, o, brace, realtype;
- union tree0 *s;
+ union tree *s;
np = *anp;
realtype = np.htype;
isarray++;
else
flex = 0;
- width = length((union tree0 *)&np);
+ width = length((union tree *)&np);
nel = 1;
/*
* If it's an array, find the number of elements.
np.hsubsp++;
if (width==0 && flex==0)
error0("0-length row: %s", anp->name);
- o = length((union tree0 *)&np);
+ o = length((union tree *)&np);
nel = (unsigned)width/o;
width = o;
}
anp->hoffset = s->c.value;
} else
rcexpr0(block(INIT,np.htype,(int *)NULL,
- (union str *)NULL, (*--cp0)->t.tr2, TNULL0));
+ (union str *)NULL, (*--cp0)->t.tr2, TNULL));
endtree(st);
}
ninit++;
case IF: {
register int o2;
- register union tree0 *np;
+ register union tree *np;
char *st = starttree();
np = pexpr(/*1*/);
goto stmt;
case SWITCH: {
- register union tree0 *np;
+ register union tree *np;
register char *st;
o1 = brklab;
st = starttree();
np = pexpr(/*0*/);
chkw(np, -1);
- rcexpr0(block(RFORCE,0,(int *)NULL,(union str *)NULL,np,TNULL0));
+ rcexpr0(block(RFORCE,0,(int *)NULL,(union str *)NULL,np,TNULL));
endtree(st);
pswitch0();
brklab = o1;
*/
int forstmt() {
register int o;
- register union tree0 *st;
+ register union tree *st;
register int l;
char *ss;
* A parenthesized expression,
* as after "if".
*/
-union tree0 *pexpr(/*eflag*/) /*int eflag;*/ {
+union tree *pexpr(/*eflag*/) /*int eflag;*/ {
register int o;
- register union tree0 *t;
+ register union tree *t;
if ((o=symbol())!=LPARN)
goto syntax;
* Structure resembling a block for a register variable.
*/
struct nmlist hreg = { REG, 0, 0, NULL, NULL, 0 };
-struct tnode0 areg = { NAME, 0, NULL, NULL, (union tree0 *)&hreg};
+struct tnode areg = { NAME, 0, NULL, NULL, 0/*degree*/, (union tree *)&hreg};
void funchead() {
register int pl;
register struct nmlist *cs;
cs->htype -= (ARRAY-PTR); /* set ptr */
cs->hsubsp++; /* pop dims */
}
- pl += rlength((union tree0 *)cs);
+ pl += rlength((union tree *)cs);
if (cs->hclass==AREG && (hreg.hoffset=goodreg(cs))>=0) {
st = starttree();
- *cp0++ = (union tree0 *)&areg;
+ *cp0++ = (union tree *)&areg;
*cp0++ = nblock(cs);
areg.type = cs->htype;
areg.strp = cs->hstrp;
isunion++;
mosflg = FMOS;
if ((peeksym=symbol()) == SEMI) {
- o = length((union tree0 *)tptr);
+ o = length((union tree *)tptr);
if (o>offset)
offset = o;
}
}
elsize = 0;
if (skw==MOS) {
- elsize = length((union tree0 *)dsym);
+ elsize = length((union tree *)dsym);
if ((peeksym = symbol())==COLON) {
elsize = 0;
peeksym = -1;
peeksym = a;
if (skw==AUTO) {
/* if (STAUTO < 0) { */
- autolen -= rlength((union tree0 *)dsym);
+ autolen -= rlength((union tree *)dsym);
dsym->hoffset = autolen;
if (autolen < maxauto)
maxauto = autolen;
outcode("B", EVEN);
} else
outcode("BBNBN", BSS, LABEL, isn0++, SSPACE,
- rlength((union tree0 *)dsym));
+ rlength((union tree *)dsym));
outcode("B", PROG);
isinit = 0;
} else if (skw==REG && isinit) {
* Make a tree0 that causes a branch0 to lbl
* if the tree0's value is non-zero together with the cond.
*/
-void cbranch0(t, lbl, cond) union tree0 *t; int lbl; int cond; {
+void cbranch0(t, lbl, cond) union tree *t; int lbl; int cond; {
treeout(t, 0);
outcode("BNNN", CBRANCH, lbl, cond, line);
}
/*
* Write out a tree0.
*/
-void rcexpr0(tp) register union tree0 *tp; {
+void rcexpr0(tp) register union tree *tp; {
/*
* Special optimization
*/
outcode("BN", EXPR, line);
}
-void treeout(tp, isstruct) register union tree0 *tp; int isstruct; {
+void treeout(tp, isstruct) register union tree *tp; int isstruct; {
register struct nmlist *hp;
register int nextisstruct;
* is some kind of pointer; return the size of the object
* to which the pointer points.
*/
-int plength(p) register union tree0 *p; {
+int plength(p) register union tree *p; {
register int t, l;
if (p==0 || ((t=p->t.type)&~TYPE) == 0) /* not a reference */
* return the number of bytes in the object
* whose tree0 node is acs.
*/
-int length(cs) union tree0 *cs; {
+int length(cs) union tree *cs; {
register int t, elsz;
long n;
int nd;
/*
* The number of bytes in an object, rounded up to a word.
*/
-int rlength(cs) union tree0 *cs; {
+int rlength(cs) union tree *cs; {
return((length(cs)+ALIGN) & ~ALIGN);
}
* The goto statement.
*/
void dogoto() {
- register union tree0 *np;
+ register union tree *np;
register char *st;
st = starttree();
*cp0++ = tree0(/*0*/);
build(STAR);
chkw(np = *--cp0, -1);
- rcexpr0(block(JUMP, 0, (int *)NULL, (union str *)NULL, np, TNULL0));
+ rcexpr0(block(JUMP, 0, (int *)NULL, (union str *)NULL, np, TNULL));
endtree(st);
}
register char *st;
st = starttree();
- *cp0++ = (union tree0 *)&funcblk0;
+ *cp0++ = (union tree *)&funcblk0;
*cp0++ = tree0(/*0*/);
build(ASSIGN);
cp0[-1] = cp0[-1]->t.tr2;
#include <setjmp.h>
#include "ccom.h"
-#ifndef NULL
-#define NULL 0
-#endif
-#define TNULL1 (union tree1 *)NULL
#define UNS(x) ((unsigned short)(x))
-/*
- * Tree node for unary and binary
- */
-struct tnode1 {
- int op;
- int type;
- int degree;
- union tree1 *tr1;
- union tree1 *tr2;
-};
-
-/*
- * tree1 names for locals
- */
-struct tname {
- int op;
- int type;
- char class;
- char regno;
- int offset;
- int nloc;
-};
-
-/*
- * tree1 names for externals
- */
-struct xtname {
- int op;
- int type;
- char class;
- char regno;
- int offset;
- char *name;
-};
-
-/*
- * short constants
- */
-struct tconst1 {
- int op;
- int type;
- _INT value;
-};
-
-/*
- * long constants
- */
-struct lconst1 {
- int op;
- int type;
- _LONG lvalue;
-};
-
-/*
- * Floating constants
- */
-struct ftconst1 {
- int op;
- int type;
- int value;
- _DOUBLE fvalue;
-};
-
-/*
- * Node used for field assignments
- */
-struct fasgn {
- int op;
- int type;
- int degree;
- union tree1 *tr1;
- union tree1 *tr2;
- int mask;
-};
-
-union tree1 {
- struct tnode1 t;
- struct tname n;
- struct xtname x;
- struct tconst1 c;
- struct lconst1 l;
- struct ftconst1 f;
- struct fasgn F;
-};
-
struct optab {
char tabdeg1;
char tabtyp1;
extern char *funcbase;
extern char *curbase;
extern char *coremax;
-extern struct tconst1 czero, cone;
+extern struct tconst czero, cone;
extern long totspace;
extern int regpanic; /* set when SU register alg. fails */
extern int panicposs; /* set when there might be need for regpanic */
extern long ftell();
/*extern char *sbrk();*/
extern struct optab *match();
-extern union tree1 *optim();
-extern union tree1 *unoptim();
-extern union tree1 *pow2();
-extern union tree1 *tnode1();
-extern union tree1 *sdelay();
-extern union tree1 *ncopy();
-extern union tree1 *getblk();
-extern union tree1 *strfunc();
-extern union tree1 *isconstant();
-extern union tree1 *tconst1();
-extern union tree1 *hardlongs();
-extern union tree1 *lconst1();
-extern union tree1 *acommute();
-extern union tree1 *lvfield();
-extern union tree1 *paint();
+extern union tree *optim();
+extern union tree *unoptim();
+extern union tree *pow2();
+extern union tree *tnode1();
+extern union tree *sdelay();
+extern union tree *ncopy();
+extern union tree *getblk();
+extern union tree *strfunc();
+extern union tree *isconstant();
+extern union tree *tconst1();
+extern union tree *hardlongs();
+extern union tree *lconst1();
+extern union tree *acommute();
+extern union tree *lvfield();
+extern union tree *paint();
extern long ftell();
/*
struct acl {
int nextl;
int nextn;
- union tree1 *nlist[LSTSIZ];
- union tree1 *llist[LSTSIZ+1];
+ union tree *nlist[LSTSIZ];
+ union tree *llist[LSTSIZ+1];
};
#endif
/* c10.c */
int main __P((int argc, char *argv[]));
-struct optab *match __P((union tree1 *tree1, struct table *table, int nrleft, int nocvt));
-int rcexpr1 __P((union tree1 *atree, struct table *atable, int reg));
-int cexpr __P((register union tree1 *tree1, struct table *table, int areg));
-int reorder __P((union tree1 **treep, struct table *table, int reg));
-int sreorder __P((union tree1 **treep, struct table *table, int reg, int recurf));
-int delay __P((union tree1 **treep, struct table *table, int reg));
-union tree1 *sdelay __P((union tree1 **ap));
-union tree1 *paint __P((register union tree1 *tp, register int type));
-union tree1 *ncopy __P((register union tree1 *p));
-int chkleaf __P((register union tree1 *tree1, struct table *table, int reg));
-int comarg __P((register union tree1 *tree1, int *flagp));
-union tree1 *strfunc __P((register union tree1 *tp));
-void doinit __P((register int type, register union tree1 *tree1));
-void movreg __P((int r0, int r1, union tree1 *tree1));
+struct optab *match __P((union tree *tree1, struct table *table, int nrleft, int nocvt));
+int rcexpr1 __P((union tree *atree, struct table *atable, int reg));
+int cexpr __P((register union tree *tree1, struct table *table, int areg));
+int reorder __P((union tree **treep, struct table *table, int reg));
+int sreorder __P((union tree **treep, struct table *table, int reg, int recurf));
+int delay __P((union tree **treep, struct table *table, int reg));
+union tree *sdelay __P((union tree **ap));
+union tree *paint __P((register union tree *tp, register int type));
+union tree *ncopy __P((register union tree *p));
+int chkleaf __P((register union tree *tree1, struct table *table, int reg));
+int comarg __P((register union tree *tree1, int *flagp));
+union tree *strfunc __P((register union tree *tp));
+void doinit __P((register int type, register union tree *tree1));
+void movreg __P((int r0, int r1, union tree *tree1));
/* c11.c */
-int degree __P((register union tree1 *t));
-void pname __P((register union tree1 *p, int flag));
-void pbase __P((register union tree1 *p));
-int xdcalc __P((register union tree1 *p, int nrleft));
-int dcalc __P((register union tree1 *p, int nrleft));
-int notcompat __P((register union tree1 *p, int ast, int deg, int op));
+int degree __P((register union tree *t));
+void pname __P((register union tree *p, int flag));
+void pbase __P((register union tree *p));
+int xdcalc __P((register union tree *p, int nrleft));
+int dcalc __P((register union tree *p, int nrleft));
+int notcompat __P((register union tree *p, int ast, int deg, int op));
int prins __P((int op, int c, struct instab *itable, int lbl));
-int collcon __P((register union tree1 *p));
-int isfloat __P((register union tree1 *t));
-int oddreg __P((register union tree1 *t, register int reg));
+int collcon __P((register union tree *p));
+int isfloat __P((register union tree *t));
+int oddreg __P((register union tree *t, register int reg));
int arlength __P((int t));
void pswitch1 __P((struct swtab *afp, struct swtab *alp, int deflab));
void breq __P((int v, int l));
int sort __P((struct swtab *afp, struct swtab *alp));
-int ispow2 __P((register union tree1 *tree1));
-union tree1 *pow2 __P((register union tree1 *tree1));
-void cbranch1 __P((union tree1 *atree, register int lbl, int cond, register int reg));
+int ispow2 __P((register union tree *tree1));
+union tree *pow2 __P((register union tree *tree1));
+void cbranch1 __P((union tree *atree, register int lbl, int cond, register int reg));
void branch1 __P((int lbl, int aop, int c));
-void longrel __P((union tree1 *atree, int lbl, int cond, int reg));
+void longrel __P((union tree *atree, int lbl, int cond, int reg));
int xlongrel __P((int f));
void label1 __P((int l));
void popstk __P((int a));
void psoct __P((int an));
void getree __P((void));
int geti __P((void));
-void strasg __P((union tree1 *atp));
+void strasg __P((union tree *atp));
int decref1 __P((register int t));
int incref1 __P((register int t));
/* c12.c */
-union tree1 *optim __P((register union tree1 *tree1));
-union tree1 *unoptim __P((register union tree1 *tree1));
-union tree1 *lvfield __P((register union tree1 *t));
-union tree1 *acommute __P((register union tree1 *tree1));
-int sideeffects __P((register union tree1 *tp));
+union tree *optim __P((register union tree *tree1));
+union tree *unoptim __P((register union tree *tree1));
+union tree *lvfield __P((register union tree *t));
+union tree *acommute __P((register union tree *tree1));
+int sideeffects __P((register union tree *tp));
void distrib __P((struct acl *list));
-void squash __P((union tree1 **p, union tree1 **maxp));
+void squash __P((union tree **p, union tree **maxp));
void _const __P((int op, register _INT *vp, _INT v, int type));
-union tree1 *lconst1 __P((int op, register union tree1 *lp, register union tree1 *rp));
-void insert __P((int op, register union tree1 *tree1, register struct acl *list));
-union tree1 *tnode1 __P((int op, int type, union tree1 *tr1, union tree1 *tr2));
-union tree1 *tconst1 __P((int val, int type));
-union tree1 *getblk __P((int size));
+union tree *lconst1 __P((int op, register union tree *lp, register union tree *rp));
+void insert __P((int op, register union tree *tree1, register struct acl *list));
+union tree *tnode1 __P((int op, int type, union tree *tr1, union tree *tr2));
+union tree *tconst1 __P((int val, int type));
+union tree *getblk __P((int size));
int islong __P((int t));
-union tree1 *isconstant __P((register union tree1 *t));
-union tree1 *hardlongs __P((register union tree1 *t));
-int uns __P((union tree1 *tp));
+union tree *isconstant __P((register union tree *t));
+union tree *hardlongs __P((register union tree *t));
+int uns __P((union tree *tp));
#ifndef pdp11
/* fp.c */
LESSEQ, GREATP, GREATQP, LESSP, LESSEQP
};
-struct tconst1 czero = { CON, INT, 0};
-struct tconst1 cone = { CON, INT, 1};
+struct tconst czero = { CON, INT, 0/*subsp*/, 0/*strp*/, 0};
+struct tconst cone = { CON, INT, 0/*subsp*/, 0/*strp*/, 1};
struct tname sfuncr = { NAME, STRUCT, STATIC, 0, 0, 0 };
* required is not too large.
* Return a ptr to the table entry or 0 if none found.
*/
-struct optab *match(tree1, table, nrleft, nocvt) union tree1 *tree1; struct table *table; int nrleft; int nocvt; {
+struct optab *match(tree1, table, nrleft, nocvt) union tree *tree1; struct table *table; int nrleft; int nocvt; {
#define NOCVL 1
#define NOCVR 2
int op, d1, d2, dope;
- union tree1 *p2;
- register union tree1 *p1;
+ union tree *p2;
+ register union tree *p1;
register struct optab *opt;
if (tree1==NULL)
* A number of special cases are recognized, and
* there is an interaction with the optimizer routines.
*/
-int rcexpr1(atree, atable, reg) union tree1 *atree; struct table *atable; int reg; {
+int rcexpr1(atree, atable, reg) union tree *atree; struct table *atable; int reg; {
register int r;
int modf, nargs, recurf;
- register union tree1 *tree1;
+ register union tree *tree1;
register struct table *table;
/*fprintf(stderr, "rcexpr1(0x%08x, 0x%08x, 0x%08x)\n", atree, atable, reg);*/
case ANDN:
if (table==cctab) {
tree1->t.op = TAND;
- tree1->t.tr2 = optim(tnode1(COMPL, tree1->t.type, tree1->t.tr2, TNULL1));
+ tree1->t.tr2 = optim(tnode1(COMPL, tree1->t.type, tree1->t.tr2, TNULL));
}
break;
if (tree1->t.tr2->t.op==ITOL)
tree1->t.tr2 = tree1->t.tr2->t.tr1;
else
- tree1->t.tr2 = optim(tnode1(LTOI,INT,tree1->t.tr2,TNULL1));
+ tree1->t.tr2 = optim(tnode1(LTOI,INT,tree1->t.tr2,TNULL));
if (tree1->t.op==ASULSH)
{
tree1->t.op = UASLSHL;
- tree1->t.tr1 = tnode1(AMPER, LONG+PTR, tree1->t.tr1, TNULL1);
+ tree1->t.tr1 = tnode1(AMPER, LONG+PTR, tree1->t.tr1, TNULL);
}
else
tree1->t.op = ULLSHIFT;
if (tree1->t.tr2->t.op==ITOL)
tree1->t.tr2 = tree1->t.tr2->t.tr1;
else
- tree1->t.tr2 = optim(tnode1(LTOI,INT,tree1->t.tr2,TNULL1));
+ tree1->t.tr2 = optim(tnode1(LTOI,INT,tree1->t.tr2,TNULL));
if (tree1->t.op==ASLSH)
tree1->t.op = ASLSHL;
else
* Special grace for unsigned chars as right operands
*/
if (opdope1[tree1->t.op]&BINARY && tree1->t.tr2->t.type==UNCHAR) {
- tree1->t.tr2 = tnode1(LOAD, UNSIGN, tree1->t.tr2, TNULL1);
+ tree1->t.tr2 = tnode1(LOAD, UNSIGN, tree1->t.tr2, TNULL);
return(rcexpr1(tree1, table, reg));
}
/*
* Most of the work is the macro-expansion of the
* code table.
*/
-int cexpr(tree1, table, areg) register union tree1 *tree1; struct table *table; int areg; {
+int cexpr(tree1, table, areg) register union tree *tree1; struct table *table; int areg; {
int c, r;
- register union tree1 *p, *p1;
+ register union tree *p, *p1;
struct table *ctable;
- union tree1 *p2;
+ union tree *p2;
char *string;
int reg, reg1, rreg, flag, opd;
struct optab *opt;
*/
if ((opd&RELAT||c==LOGAND||c==LOGOR||c==EXCLA) && table!=cctab) {
cbranch1(tree1, c=isn1++, 1, reg);
- rcexpr1((union tree1 *)&czero, table, reg);
+ rcexpr1((union tree *)&czero, table, reg);
branch1(isn1, 0, 0);
label1(c);
- rcexpr1((union tree1 *)&cone, table, reg);
+ rcexpr1((union tree *)&cone, table, reg);
label1(isn1++);
return(reg);
}
if (tree1->t.tr2 && (tree1->t.tr2->t.op==AUTOI||tree1->t.tr2->t.op==AUTOD)
&& (tree1->t.tr1->t.type==CHAR || tree1->t.tr1->t.type==UNCHAR)
&& tree1->t.tr2->t.type!=CHAR && tree1->t.tr2->t.type!=UNCHAR)
- tree1->t.tr2 = tnode1(LOAD, tree1->t.tr2->t.type, tree1->t.tr2, TNULL1);
+ tree1->t.tr2 = tnode1(LOAD, tree1->t.tr2->t.type, tree1->t.tr2, TNULL);
/*
* Another peculiarity of the PDP11 table manifested itself when
* amplifying the move3: table. The same case which optimizes
if (tree1->t.tr2 && tree1->t.tr1->t.op == NAME
&& tree1->t.tr1->n.class == REG && tree1->t.op == ASSIGN
&& tree1->t.tr2->t.type == UNCHAR)
- tree1->t.tr2 = tnode1(LOAD, UNSIGN, tree1->t.tr2, TNULL1);
+ tree1->t.tr2 = tnode1(LOAD, UNSIGN, tree1->t.tr2, TNULL);
if (table==cregtab)
table = regtab;
/*
* on the subtrees and then on the tree1 itself.
* It returns non-zero if anything changed.
*/
-int reorder(treep, table, reg) union tree1 **treep; struct table *table; int reg; {
+int reorder(treep, table, reg) union tree **treep; struct table *table; int reg; {
register int r, o;
- register union tree1 *p;
+ register union tree *p;
p = *treep;
o = p->t.op;
* Moreover, expressions like "reg = x+y" are best done as
* "reg = x; reg += y" (so long as "reg" and "y" are not the same!).
*/
-int sreorder(treep, table, reg, recurf) union tree1 **treep; struct table *table; int reg; int recurf; {
- register union tree1 *p, *p1;
+int sreorder(treep, table, reg, recurf) union tree **treep; struct table *table; int reg; int recurf; {
+ register union tree *p, *p1;
p = *treep;
if (opdope1[p->t.op]&LEAF)
if (p->t.op==PLUS && recurf)
if (reorder(&p->t.tr2, table, reg))
*treep = p = optim(p);
- if ((p1 = p->t.tr1)==TNULL1)
+ if ((p1 = p->t.tr1)==TNULL)
return(0);
if (p->t.op==STAR || p->t.op==PLUS) {
if (recurf && reorder(&p->t.tr1, table, reg)) {
* Otherwise it uses sdelay to search for inc/dec
* among the operands.
*/
-int delay(treep, table, reg) union tree1 **treep; struct table *table; int reg; {
- register union tree1 *p, *p1;
+int delay(treep, table, reg) union tree **treep; struct table *table; int reg; {
+ register union tree *p, *p1;
register int r;
p = *treep;
return(0);
}
-union tree1 *sdelay(ap) union tree1 **ap; {
- register union tree1 *p, *p1;
+union tree *sdelay(ap) union tree **ap; {
+ register union tree *p, *p1;
- if ((p = *ap)==TNULL1)
- return(TNULL1);
+ if ((p = *ap)==TNULL)
+ return(TNULL);
if ((p->t.op==INCAFT||p->t.op==DECAFT) && p->t.tr1->t.op==NAME) {
*ap = paint(ncopy(p->t.tr1), p->t.type);
return(p);
/*
* Propagate possible implicit type-changing operation
*/
-union tree1 *paint(tp, type) register union tree1 *tp; register int type; {
+union tree *paint(tp, type) register union tree *tp; register int type; {
if (tp->t.type==type)
return(tp);
if (tp->t.type==CHAR && type==INT)
return(tp);
if (tp->t.type==CHAR || tp->t.type==UNCHAR)
- return(optim(tnode1(LOAD, type, tp, TNULL1)));
+ return(optim(tnode1(LOAD, type, tp, TNULL)));
tp->t.type = type;
if (tp->t.op==AMPER && type&XTYPE)
tp->t.tr1 = paint(tp->t.tr1, decref1(type));
* be changed to some offset class, accidentally
* modifying the reg--.
*/
-union tree1 *ncopy(p) register union tree1 *p; {
- register union tree1 *q;
+union tree *ncopy(p) register union tree *p; {
+ register union tree *q;
q = getblk(sizeof(struct xtname));
q->n.op = p->n.op;
* If the tree1 can be immediately loaded into a register,
* produce code to do so and return success.
*/
-int chkleaf(tree1, table, reg) register union tree1 *tree1; struct table *table; int reg; {
- struct tnode1 lbuf;
+int chkleaf(tree1, table, reg) register union tree *tree1; struct table *table; int reg; {
+ struct tnode lbuf;
/*fprintf(stderr, "chkleaf(0x%08x, 0x%08x, 0x%08x)\n", tree1, table, reg);*/
if (tree1->t.op!=STAR && dcalc(tree1, nreg-reg) > 12)
#if 1 /* can't have garbage in lbuf.tr2, cexpr() will deref it if non-NULL */
lbuf.tr2 = NULL;
#endif
- return(rcexpr1((union tree1 *)&lbuf, table, reg));
+ return(rcexpr1((union tree *)&lbuf, table, reg));
}
/*
* Return the number of bytes pushed,
* for future popping.
*/
-int comarg(tree1, flagp) register union tree1 *tree1; int *flagp; {
+int comarg(tree1, flagp) register union tree *tree1; int *flagp; {
register int retval;
int i;
int size;
error1("Unimplemented structure assignment");
return(0);
}
- tree1 = tnode1(AMPER, STRUCT+PTR, tree1, TNULL1);
+ tree1 = tnode1(AMPER, STRUCT+PTR, tree1, TNULL);
tree1 = tnode1(PLUS, STRUCT+PTR, tree1, tconst1(size, INT));
tree1 = optim(tree1);
retval = rcexpr1(tree1, regtab, 0);
return(retval);
}
-union tree1 *strfunc(tp) register union tree1 *tp; {
+union tree *strfunc(tp) register union tree *tp; {
if (tp->t.op != CALL)
return(tp);
paint(tp, STRUCT+PTR);
- return(tnode1(STAR, STRUCT, tp, TNULL1));
+ return(tnode1(STAR, STRUCT, tp, TNULL));
}
/*
* Compile an initializing expression
*/
-void doinit(type, tree1) register int type; register union tree1 *tree1; {
+void doinit(type, tree1) register int type; register union tree *tree1; {
_FLOAT sfval;
_DOUBLE fval;
_LONG lval;
error1("Illegal initialization");
}
-void movreg(r0, r1, tree1) int r0; int r1; union tree1 *tree1; {
+void movreg(r0, r1, tree1) int r0; int r1; union tree *tree1; {
register char *s;
char c;
/*static void outname __P((char *s));*/
static void outname __P((char *buf, char *str));
-int degree(t) register union tree1 *t; {
- register union tree1 *t1;
+int degree(t) register union tree *t; {
+ register union tree *t1;
if (t==NULL || t->t.op==0)
return(0);
return(t->t.degree);
}
-void pname(p, flag) register union tree1 *p; int flag; {
+void pname(p, flag) register union tree *p; int flag; {
register int i;
loop:
error1("compiler error1: bad pname");
}
-void pbase(p) register union tree1 *p; {
+void pbase(p) register union tree *p; {
if (p->n.class==SOFFS || p->n.class==STATIC)
fprintf(temp_fp[temp_fi], /*printf(*/"L%d", p->n.nloc);
fprintf(temp_fp[temp_fi], /*printf(*/"%s", p->x.name);
}
-int xdcalc(p, nrleft) register union tree1 *p; int nrleft; {
+int xdcalc(p, nrleft) register union tree *p; int nrleft; {
register int d;
if (p==NULL)
return(d);
}
-int dcalc(p, nrleft) register union tree1 *p; int nrleft; {
- register union tree1 *p1;
+int dcalc(p, nrleft) register union tree *p; int nrleft; {
+ register union tree *p1;
if (p==NULL)
return(0);
return(p->t.degree <= nrleft? 20: 24);
}
-int notcompat(p, ast, deg, op) register union tree1 *p; int ast; int deg; int op; {
+int notcompat(p, ast, deg, op) register union tree *p; int ast; int deg; int op; {
unsigned register at, st;
at = p->t.type;
return(skip);
}
-int collcon(p) register union tree1 *p; {
+int collcon(p) register union tree *p; {
register int op;
if (p==NULL)
return(0);
}
-int isfloat(t) register union tree1 *t; {
+int isfloat(t) register union tree *t; {
if ((opdope1[t->t.op]&RELAT)!=0)
t = t->t.tr1;
return(0);
}
-int oddreg(t, reg) register union tree1 *t; register int reg; {
+int oddreg(t, reg) register union tree *t; register int reg; {
if (!isfloat(t)) {
if (opdope1[t->t.op]&RELAT) {
return(0);
}
-int ispow2(tree1) register union tree1 *tree1; {
+int ispow2(tree1) register union tree *tree1; {
register int d;
if (!isfloat(tree1) && tree1->t.tr2->t.op==CON) {
return(0);
}
-union tree1 *pow2(tree1) register union tree1 *tree1; {
+union tree *pow2(tree1) register union tree *tree1; {
register int d, i;
if (d = ispow2(tree1)) {
case PTOI:
if (i==1 && tree1->t.tr1->t.op==MINUS && !isconstant(tree1->t.tr1->t.tr2)) {
tree1->t.op = PTOI1;
- tree1->t.tr1 = tnode1(LTOI, INT, tree1->t.tr1, TNULL1);
+ tree1->t.tr1 = tnode1(LTOI, INT, tree1->t.tr1, TNULL);
return(optim(tree1));
}
tree1->t.op = LLSHIFT;
tree1->t.tr2->c.value = -i;
i = tree1->t.type;
tree1->t.type = LONG;
- tree1 = tnode1(LTOI, i, tree1, TNULL1);
+ tree1 = tnode1(LTOI, i, tree1, TNULL);
break;
case DIVIDE:
return(tree1);
}
-void cbranch1(atree, lbl, cond, reg) union tree1 *atree; register int lbl; int cond; register int reg; {
+void cbranch1(atree, lbl, cond, reg) union tree *atree; register int lbl; int cond; register int reg; {
int l1, op;
- register union tree1 *tree1;
+ register union tree *tree1;
again:
if ((tree1=atree)==NULL)
fprintf(temp_fp[temp_fi], /*printf(*/"\tL%d\n", lbl);
}
-void longrel(atree, lbl, cond, reg) union tree1 *atree; int lbl; int cond; int reg; {
+void longrel(atree, lbl, cond, reg) union tree *atree; int lbl; int cond; int reg; {
int xl1, xl2, xo, xz;
register int op, isrel;
- register union tree1 *tree1;
+ register union tree *tree1;
if (reg&01)
reg++;
&& tree1->t.tr2->t.tr1->c.value==0);
if (tree1->t.op==ANDN) {
tree1->t.op = TAND;
- tree1->t.tr2 = optim(tnode1(COMPL, LONG, tree1->t.tr2, TNULL1));
+ tree1->t.tr2 = optim(tnode1(COMPL, LONG, tree1->t.tr2, TNULL));
}
if (cexpr(tree1, cctab, reg) < 0) {
reg = rcexpr1(tree1, regtab, reg);
#endif
{
va_list argp;
- /* union tree1 *expstack[STKS], **sp;*/
- static union tree1 *expstack[STKS], **sp = expstack;
- register union tree1 *tp;
+ /* union tree *expstack[STKS], **sp;*/
+ static union tree *expstack[STKS], **sp = expstack;
+ register union tree *tp;
register int t, op;
char s[80]; /* big for asm() stuff & long variable names */
struct swtab *swp;
rcexpr1(tp, efftab, 0);
else {
if (tp->t.type==LONG || tp->t.type==UNLONG) {
- rcexpr1(tnode1(RFORCE, tp->t.type, tp, TNULL1), efftab, 0);
+ rcexpr1(tnode1(RFORCE, tp->t.type, tp, TNULL), efftab, 0);
fprintf(temp_fp[temp_fi], /*printf(*/"ashc $0,r0\n");
} else {
rcexpr1(tp, cctab, 0);
t = va_arg(argp, int) /*geti()*/;
op = va_arg(argp, int) /*geti()*/;
if (t==0 && op>=0 || t == -1 && op<0) {
- *sp++ = tnode1(ITOL, LONG, tconst1(op, INT), TNULL1);
+ *sp++ = tnode1(ITOL, LONG, tconst1(op, INT), TNULL);
break;
}
- tp = getblk(sizeof(struct lconst1));
+ tp = getblk(sizeof(struct lconst));
tp->t.op = LCON;
tp->t.type = LONG;
tp->l.lvalue = ((_LONG)t<<16) + UNS(op); /* nonportable */
case FCON:
t = va_arg(argp, int) /*geti()*/;
outname(s/*)*/, va_arg(argp, char *));
- tp = getblk(sizeof(struct ftconst1));
+ tp = getblk(sizeof(struct ftconst));
tp->t.op = FCON;
tp->t.type = t;
tp->f.value = isn1++;
break;
case FSEL:
- tp = tnode1(FSEL, va_arg(argp, int) /*geti()*/, *--sp, TNULL1);
+ tp = tnode1(FSEL, va_arg(argp, int) /*geti()*/, *--sp, TNULL);
t = va_arg(argp, int) /*geti()*/;
tp->t.tr2 = tnode1(COMMA, INT, tconst1(va_arg(argp, int) /*geti()*/, INT), tconst1(t, INT));
if (tp->t.tr2->t.tr1->c.value==16)
break;
case NULLOP:
- *sp++ = tnode1(0, 0, TNULL1, TNULL1);
+ *sp++ = tnode1(0, 0, TNULL, TNULL);
break;
case LABEL:
*sp++ = tnode1(op, va_arg(argp, int) /*geti()*/, *--sp, tp);
#endif
} else
- sp[-1] = tnode1(op, va_arg(argp, int) /*geti()*/, sp[-1], TNULL1);
+ sp[-1] = tnode1(op, va_arg(argp, int) /*geti()*/, sp[-1], TNULL);
break;
}
}
}
#endif
-void strasg(atp) union tree1 *atp; {
- register union tree1 *tp;
+void strasg(atp) union tree *atp; {
+ register union tree *tp;
register int nwords, i;
nwords = atp->F.mask/sizeof(_INT);
fprintf(temp_fp[temp_fi], /*printf(*/".bss\nL%d:.=.+%o\n.text\n", sfuncr.nloc,
UNS(nwords*sizeof(_INT)));
}
- atp->t.tr1 = tnode1(ASSIGN, STRUCT, (union tree1 *)&sfuncr, tp->t.tr1);
+ atp->t.tr1 = tnode1(ASSIGN, STRUCT, (union tree *)&sfuncr, tp->t.tr1);
strasg(atp);
fprintf(temp_fp[temp_fi], /*printf(*/"mov $L%d,r0\n", sfuncr.nloc);
return;
error1("unimplemented structure assignment");
return;
}
- tp->t.tr1 = tnode1(AMPER, STRUCT+PTR, tp->t.tr1, TNULL1);
- tp->t.tr2 = tnode1(AMPER, STRUCT+PTR, tp->t.tr2, TNULL1);
+ tp->t.tr1 = tnode1(AMPER, STRUCT+PTR, tp->t.tr1, TNULL);
+ tp->t.tr2 = tnode1(AMPER, STRUCT+PTR, tp->t.tr2, TNULL);
tp->t.op = STRSET;
tp->t.type = STRUCT+PTR;
tp = optim(tp);
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
-union tree1 *optim(tree1) register union tree1 *tree1; {
+union tree *optim(tree1) register union tree *tree1; {
register int op, dope;
int d1, d2;
- union tree1 *t;
+ union tree *t;
#ifdef pdp11
union { double dv; _INT iv[4];} fp11;
#endif
*/
case ASAND:
tree1->t.op = ASANDN;
- tree1->t.tr2 = tnode1(COMPL, tree1->t.tr2->t.type, tree1->t.tr2, TNULL1);
+ tree1->t.tr2 = tnode1(COMPL, tree1->t.tr2->t.type, tree1->t.tr2, TNULL);
break;
/*
*/
case LTOP:
tree1->t.op = ITOP;
- tree1->t.tr1 = unoptim(tnode1(LTOI,INT,tree1->t.tr1, TNULL1));
+ tree1->t.tr1 = unoptim(tnode1(LTOI,INT,tree1->t.tr1, TNULL));
case ITOP:
tree1->t.op = TIMES;
break;
t = tree1->t.tr2;
tree1->t.tr2 = tree1->t.tr2->t.tr1;
t->t.tr1 = tree1;
- tree1->t.tr1 = tnode1(LTOI, UNSIGN, tree1->t.tr1, TNULL1);
+ tree1->t.tr1 = tnode1(LTOI, UNSIGN, tree1->t.tr1, TNULL);
return(optim(t));
}
/*
}
tree1->t.op = ANDN;
op = ANDN;
- tree1->t.tr2 = tnode1(COMPL, tree1->t.tr2->t.type, tree1->t.tr2, TNULL1);
+ tree1->t.tr2 = tnode1(COMPL, tree1->t.tr2->t.type, tree1->t.tr2, TNULL);
}
again:
tree1->t.tr1 = optim(tree1->t.tr1);
case ASTIMES:
if (tree1->t.tr2->t.op==CON && tree1->t.tr2->c.value==1) {
if (op==PTOI)
- return(optim(tnode1(LTOI,INT,paint(tree1->t.tr1,LONG), TNULL1)));
+ return(optim(tnode1(LTOI,INT,paint(tree1->t.tr1,LONG), TNULL)));
return(paint(tree1->t.tr1, tree1->t.type));
}
case MOD:
goto constant;
op += (LSHIFT-RSHIFT);
tree1->t.op = op;
- tree1->t.tr2 = tnode1(NEG, tree1->t.tr2->t.type, tree1->t.tr2, TNULL1);
+ tree1->t.tr2 = tnode1(NEG, tree1->t.tr2->t.type, tree1->t.tr2, TNULL);
if (uns(tree1->t.tr1) || uns(tree1->t.tr2)) {
if (tree1->t.op==LSHIFT)
tree1->t.op = ULSH;
tree1 = tree1->t.tr1;
switch(op) {
case GREATEQ:
- return((union tree1 *)&cone);
+ return((union tree *)&cone);
case LESS:
- return((union tree1 *)&czero);
+ return((union tree *)&czero);
case LESSEQ:
case EQUAL:
tree1->t.op = notrel[tree1->t.op-EQUAL];
return(tree1);
}
-union tree1 *unoptim(tree1) register union tree1 *tree1; {
- register union tree1 *subtre, *p;
+union tree *unoptim(tree1) register union tree *tree1; {
+ register union tree *subtre, *p;
if (tree1==NULL)
return(NULL);
case ITOL:
if (subtre->t.op==CON && subtre->t.type==INT && subtre->c.value<0) {
- subtre = getblk(sizeof(struct lconst1));
+ subtre = getblk(sizeof(struct lconst));
subtre->t.op = LCON;
subtre->t.type = LONG;
subtre->l.lvalue = tree1->t.tr1->c.value;
if (uns(tree1)) {
tree1->t.op = FTOL;
tree1->t.type = LONG;
- tree1 = tnode1(LTOI, UNSIGN, tree1, TNULL1);
+ tree1 = tnode1(LTOI, UNSIGN, tree1, TNULL);
}
break;
case LTOF:
if (subtre->t.op==LCON) {
- tree1 = getblk(sizeof(struct ftconst1));
+ tree1 = getblk(sizeof(struct ftconst));
tree1->t.op = FCON;
tree1->t.type = DOUBLE;
tree1->f/*c*/.value = isn1++;
case ITOF:
if (subtre->t.op==CON) {
- tree1 = getblk(sizeof(struct ftconst1));
+ tree1 = getblk(sizeof(struct ftconst));
tree1->t.op = FCON;
tree1->t.type = DOUBLE;
tree1->f.value = isn1++;
return(optim(tree1));
}
if (uns(subtre)) {
- tree1->t.tr1 = tnode1(ITOL, LONG, subtre, TNULL1);
+ tree1->t.tr1 = tnode1(ITOL, LONG, subtre, TNULL);
tree1->t.op = LTOF;
return(optim(tree1));
}
case ANDN:
case OR:
case EXOR:
- subtre->t.tr2 = tnode1(LTOI, tree1->t.type, subtre->t.tr2, TNULL1);
+ subtre->t.tr2 = tnode1(LTOI, tree1->t.type, subtre->t.tr2, TNULL);
case NEG:
case COMPL:
- subtre->t.tr1 = tnode1(LTOI, tree1->t.type, subtre->t.tr1, TNULL1);
+ subtre->t.tr1 = tnode1(LTOI, tree1->t.type, subtre->t.tr1, TNULL);
subtre->t.type = tree1->t.type;
return(optim(subtre));
}
}
if (subtre->t.op==ITOL) {
if (subtre->t.tr1->t.op==CON) {
- tree1 = getblk(sizeof(struct lconst1));
+ tree1 = getblk(sizeof(struct lconst));
tree1->t.op = LCON;
tree1->t.type = LONG;
if (uns(subtre->t.tr1))
return(subtre);
}
if (subtre->t.op==ITOL && subtre->t.tr1->t.op==CON) {
- tree1 = getblk(sizeof(struct lconst1));
+ tree1 = getblk(sizeof(struct lconst));
tree1->t.op = LCON;
tree1->t.type = LONG;
if (uns(subtre->t.tr1))
* Pure assignment is handled specially.
*/
-union tree1 *lvfield(t) register union tree1 *t; {
- register union tree1 *t1, *t2;
+union tree *lvfield(t) register union tree *t; {
+ register union tree *t1, *t2;
switch (t->t.op) {
struct acl {
int nextl;
int nextn;
- union tree1 *nlist[LSTSIZ];
- union tree1 *llist[LSTSIZ+1];
+ union tree *nlist[LSTSIZ];
+ union tree *llist[LSTSIZ+1];
};
#endif
-union tree1 *acommute(tree1) register union tree1 *tree1; {
+union tree *acommute(tree1) register union tree *tree1; {
struct acl acl;
int d, i, op, flt, d1, type;
- register union tree1 *t1, **t2;
- union tree1 *t;
+ register union tree *t1, **t2;
+ union tree *t;
acl.nextl = 0;
acl.nextn = 0;
}
if (acl.nextl <= 0) {
if ((*t2)->t.type==CHAR || (*t2)->t.type==UNCHAR)
- *t2 = tnode1(LOAD, tree1->t.type, *t2, TNULL1);
+ *t2 = tnode1(LOAD, tree1->t.type, *t2, TNULL);
(*t2)->t.type = tree1->t.type;
return(*t2);
}
* rt. op of ^ must be in a register.
*/
if (op==EXOR && dcalc(t, 0)<=12) {
- t1->t.tr2 = t = optim(tnode1(LOAD, t->t.type, t, TNULL1));
+ t1->t.tr2 = t = optim(tnode1(LOAD, t->t.type, t, TNULL));
d1 = t->t.degree;
}
t1->t.degree = d = d==d1? d+islong(t1->t.type): max(d, d1);
return(tree1);
}
-int sideeffects(tp) register union tree1 *tp; {
+int sideeffects(tp) register union tree *tp; {
register int dope;
if (tp==NULL)
* fewest divisors. Reduce this pair to c1*(y+c2*x)
* and iterate until no reductions occur.
*/
- register union tree1 **p1, **p2;
- union tree1 *t;
+ register union tree **p1, **p2;
+ union tree *t;
int ndmaj, ndmin;
- union tree1 **dividend, **divisor;
- union tree1 **maxnod, **mindiv;
+ union tree **dividend, **divisor;
+ union tree **maxnod, **mindiv;
loop:
maxnod = &list->llist[list->nextl];
goto loop;
}
-void squash(p, maxp) union tree1 **p; union tree1 **maxp; {
- register union tree1 **np;
+void squash(p, maxp) union tree **p; union tree **maxp; {
+ register union tree **np;
for (np = p; np < maxp; np++)
*np = *(np+1);
error1("C error1: const");
}
-union tree1 *lconst1(op, lp, rp) int op; register union tree1 *lp; register union tree1 *rp; {
+union tree *lconst1(op, lp, rp) int op; register union tree *lp; register union tree *rp; {
_UNSIGNED_LONG l, r;
if (lp->t.op==LCON)
lp->l.lvalue = l;
return(lp);
}
- lp = getblk(sizeof(struct lconst1));
+ lp = getblk(sizeof(struct lconst));
lp->t.op = LCON;
lp->t.type = LONG;
lp->l.lvalue = l;
return(lp);
}
-void insert(op, tree1, list) int op; register union tree1 *tree1; register struct acl *list; {
+void insert(op, tree1, list) int op; register union tree *tree1; register struct acl *list; {
register int d;
int d1, i;
- union tree1 *t;
+ union tree *t;
ins:
if (tree1->t.op != op)
list->llist[list->nextl++] = tree1;
}
-union tree1 *tnode1(op, type, tr1, tr2) int op; int type; union tree1 *tr1; union tree1 *tr2; {
- register union tree1 *p;
+union tree *tnode1(op, type, tr1, tr2) int op; int type; union tree *tr1; union tree *tr2; {
+ register union tree *p;
- p = getblk(sizeof(struct tnode1));
+ p = getblk(sizeof(struct tnode));
p->t.op = op;
p->t.type = type;
p->t.degree = 0;
return(p);
}
-union tree1 *tconst1(val, type) int val; int type; {
- register union tree1 *p;
+union tree *tconst1(val, type) int val; int type; {
+ register union tree *p;
- p = getblk(sizeof(struct tconst1));
+ p = getblk(sizeof(struct tconst));
p->t.op = CON;
p->t.type = type;
p->c.value = val;
return(p);
}
-union tree1 *getblk(size) int size; {
+union tree *getblk(size) int size; {
#if 1
- return (union tree1 *)Tblock(size);
+ return (union tree *)Tblock(size);
#else
- register union tree1 *p;
+ register union tree *p;
if (size&01)
size++;
- p = (union tree1 *)curbase;
+ p = (union tree *)curbase;
if ((curbase += size) >= coremax) {
#ifdef pdp11
if (sbrk(1024) == (char *)-1) {
return(1);
}
-union tree1 *isconstant(t) register union tree1 *t; {
+union tree *isconstant(t) register union tree *t; {
if (t->t.op==CON || t->t.op==SFCON)
return(t);
if (t->t.op==ITOL && t->t.tr1->t.op==CON)
return(NULL);
}
-union tree1 *hardlongs(t) register union tree1 *t; {
+union tree *hardlongs(t) register union tree *t; {
switch(t->t.op) {
case TIMES:
t->t.op += ULASTIMES-ASTIMES;
else
t->t.op += LASTIMES-ASTIMES;
- t->t.tr1 = tnode1(AMPER, LONG+PTR, t->t.tr1, TNULL1);
+ t->t.tr1 = tnode1(AMPER, LONG+PTR, t->t.tr1, TNULL);
break;
default:
/*
* Is tree1 of unsigned type?
*/
-int uns(tp) union tree1 *tp; {
+int uns(tp) union tree *tp; {
register int t;
t = tp->t.type;
typedef struct { uint32_t l; uint32_t h; } _DOUBLE;
#endif
+#ifndef NULL
+#define NULL 0
+#endif
+#define TNULL (union tree *)NULL
+
+/*
+ * Tree node for unary and binary
+ */
+struct tnode {
+ int op;
+ int type;
+ int *subsp; /* subscript list for arrays; pass 0 only */
+ union str *strp; /* structure descr for structs; pass 0 only */
+ int degree; /* pass 1 only */
+ union tree *tr1;
+ union tree *tr2;
+};
+
+/*
+ * tree1 names for locals
+ */
+struct tname {
+ int op;
+ int type;
+ char class;
+ char regno;
+ int offset;
+ int nloc;
+};
+
+/*
+ * tree1 names for externals
+ */
+struct xtname {
+ int op;
+ int type;
+ char class;
+ char regno;
+ int offset;
+ char *name;
+};
+
+/*
+ * short constants
+ */
+struct tconst {
+ int op;
+ int type;
+ int *subsp; /* subscript list for arrays; pass 0 only */
+ union str *strp; /* structure descr for structs; pass 0 only */
+ _INT value;
+};
+
+/*
+ * long constants
+ */
+struct lconst {
+ int op;
+ int type;
+ int *subsp; /* subscript list for arrays; pass 0 only */
+ union str *strp; /* structure descr for structs; pass 0 only */
+ _LONG lvalue;
+};
+
+/*
+ * Floating constants
+ */
+struct ftconst {
+ int op;
+ int type;
+ int *subsp; /* subscript list for arrays; pass 0 only */
+ union str *strp; /* structure descr for structs; pass 0 only */
+ char *cstr; /* pass 0 only */
+ int value; /* pass 1 only */
+ _DOUBLE fvalue; /* pass 1 only */
+};
+
+/*
+ * Node used for field assignments
+ */
+struct fasgn {
+ int op;
+ int type;
+ int *subsp; /* subscript list for arrays; pass 0 only */
+ union str *strp; /* structure descr for structs; pass 0 only */
+ int degree; /* pass 1 only */
+ union tree *tr1;
+ union tree *tr2;
+ int mask;
+};
+
+union tree {
+ struct tnode t;
+ struct tname n; /* pass 1 only */
+ struct xtname x; /* pass 1 only */
+ struct tconst c;
+ struct lconst l;
+ struct ftconst f;
+ struct fasgn F; /* pass 1 only */
+};
+
/*
* Table for recording switches.
*/
--- /dev/null
+s/@/ATSIGN/g
+s/^/@/
+s/$/@/
+s/[^A-Za-z0-9_]\+/@&@/g
+
+s/@\(TNULL\)[01]@/@\1@/g
+s/@\(union@[ ]*@tree\)[01]@/@\1@/g
+s/@\(struct@[ ]*@tnode\)[01]@/@\1@/g
+s/@\(struct@[ ]*@tconst\)[01]@/@\1@/g
+s/@\(struct@[ ]*@lconst\)[01]@/@\1@/g
+s/@\(struct@[ ]*@ftconst\)[01]@/@\1@/g
+
+s/@//g
+s/ATSIGN/@/g