register struct tnode
*t
, *t1
;
if ((t
=at
)==0 || t
->op
==0)
if (t
->op
==ITOL
&& (t1
= isconstant(t
)) && t1
->value
>= 0)
if ((opdope
[t
->op
] & LEAF
) != 0) {
if (t
->type
==CHAR
|| t
->type
==FLOAT
)
register struct tnode
*p
;
printf("(r%d)", p
->regno
);
error("Compiler error: pname");
if (p
->op
==NAME
&& p
->class==REG
)
printf("(r%d)%c", p
->nloc
, flag
==1?0:'+');
printf("%c(r%d)", flag
==1?0:'-', p
->nloc
);
error("pname called illegally");
error("Illegal use of register");
register struct tnode
*p
;
if (p
->class==SOFFS
|| p
->class==STATIC
)
printf("_%.8s", &(p
->nloc
));
register struct tnode
*p
;
if (d
<20 && p
->type
==CHAR
) {
register struct tnode
*p
, *p1
;
if (p1
->op
==NAME
||p1
->op
==CON
||p1
->op
==AUTOI
||p1
->op
==AUTOD
)
return(p
->degree
<= nrleft
? 20: 24);
register struct tnode
*p
;
if (st
==0) /* word, byte */
return(at
>CHAR
&& at
<PTR
);
return(at
>INT
&& at
<PTR
);
if ((at
&(~(TYPE
+XTYPE
))) != 0)
if (st
==FLOAT
&& at
==DOUBLE
)
if (p
->op
==NAME
&& p
->class==REG
&& op
==ASSIGN
&& st
==CHAR
)
register struct instab
*insp
;
for (insp
=itable
; insp
->op
!= 0; insp
++) {
ip
= c
? insp
->str2
: insp
->str1
;
error("No match' for op %d", op
);
register struct tnode
*p
;
if (op
==CON
|| op
==AMPER
)
register struct tnode
*t
;
if ((opdope
[t
->op
]&RELAT
)!=0)
if (t
->type
==FLOAT
|| t
->type
==DOUBLE
) {
* Strings for switch code.
pswitch(afp
, alp
, deflab
)
int tlab
, ncase
, i
, j
, tabs
, worst
, best
, range
;
register struct swtab
*swp
, *fp
, *lp
;
printf("jbr L%d\n", deflab
);
range
= lp
->swval
- fp
->swval
;
if (range
>0 && range
<= 3*ncase
) {
printf("sub $%o,r0\n", fp
->swval
);
printf(dirsw
, range
, deflab
, isn
, isn
);
for (i
=fp
->swval
; i
<=lp
->swval
; i
++) {
printf("L%d\n", fp
->swlab
);
printf(simpsw
, i
, j
, isn
, isn
, j
, i
, i
);
printf("%o\n", fp
->swval
);
for (fp
= afp
; fp
<=lp
; fp
++)
printf("L%d\n", fp
->swlab
);
for (i
=ncase
/4; i
<=ncase
/2; i
++) {
for (swp
=fp
; swp
<=lp
; swp
++)
poctab
[lrem(0, swp
->swval
, i
)]++;
printf(hashsw
, tabs
, isn
, i
, i
, isn
+tabs
+1, isn
+1, isn
);
printf("L%d:..\n", isn
++);
for (swp
=fp
; swp
<=lp
; swp
++)
if (lrem(0, swp
->swval
, tabs
) == i
)
printf("%o\n", ldiv(0, swp
->swval
, tabs
));
for (swp
=fp
; swp
<=lp
; swp
++)
if (lrem(0, swp
->swval
, tabs
) == i
)
printf("L%d\n", swp
->swlab
);
register struct swtab
*cp
, *fp
, *lp
;
for (cp
=fp
; cp
<lp
; cp
++) {
if (cp
->swval
== cp
[1].swval
) {
error("Duplicate case (%d)", cp
->swval
);
if (cp
->swval
> cp
[1].swval
) {
register struct tnode
*tree
;
if (!isfloat(tree
) && tree
->tr2
->op
==CON
) {
register struct tnode
*tree
;
for (i
=0; (d
=>>1)!=0; i
++);
tree
->op
= d
==TIMES
? LSHIFT
:
(d
==ASTIMES
? ASLSH
: ASRSH
));
cbranch(atree
, albl
, cond
, areg
)
register struct tnode
*tree
;
cbranch(tree
->tr1
, l1
=isn
++, 0, reg
);
cbranch(tree
->tr2
, lbl
, 1, reg
);
cbranch(tree
->tr1
, lbl
, 0, reg
);
cbranch(tree
->tr2
, lbl
, 0, reg
);
cbranch(tree
->tr1
, lbl
, 1, reg
);
cbranch(tree
->tr2
, lbl
, 1, reg
);
cbranch(tree
->tr1
, l1
=isn
++, 1, reg
);
cbranch(tree
->tr2
, lbl
, 0, reg
);
cbranch(tree
->tr1
, lbl
, !cond
, reg
);
rcexpr(tree
->tr1
, efftab
, reg
);
if (tree
->type
==LONG
|| opdope
[op
]&RELAT
&&tree
->tr1
->type
==LONG
) {
rcexpr(tree
, cctab
, reg
);
if ((opdope
[op
]&RELAT
)==0)
if ((l1
==CON
|| l1
==SFCON
) && tree
->tr2
->value
==0)
op
=+ 200; /* special for ptr tests */
printf("cmp (sp)+,(sp)+\n");
printf("add $%o,sp\n", a
);
error(s
, p1
, p2
, p3
, p4
, p5
, p6
)
printf(s
, p1
, p2
, p3
, p4
, p5
, p6
);
* Read in an intermediate file.
struct tnode
*expstack
[20];
register struct tnode
**sp
;
if ((op
&0177400) != 0177000) {
error("Intermediate file error");
printf(".globl _%s\n", outname(s
));
printf(".comm _%s,%o\n", t
, getw(ascbuf
));
printf(".=.+%o\n", getw(ascbuf
));
printf("sub $%o,sp\n", t
);
printf("mov $L%d,r0\njsr pc,mcount\n", t
);
printf(".bss\nL%d:.=.+2\n.text\n", t
);
printf("~%s=L%d\n", t
, getw(ascbuf
));
printf("~%s=%o\n", t
, getw(ascbuf
));
printf("~%s=r%d\n", t
, getw(ascbuf
));
while (swp
->swlab
= getw(ascbuf
)) {
swp
->swval
= getw(ascbuf
);
pswitch(treespace
, swp
, t
);
if (sp
!= &expstack
[1]) {
error("Expression input botch\n");
rcexpr(optim(*--sp
), efftab
, 0);
*sp
= block(6, NAME
, t
, 0, EXTERN
, 0, 0,0,0,0);
*sp
= block(3, NAME
, 0, 0, t
, 0, 0);
(*sp
)->type
= getw(ascbuf
);
(*sp
)->nloc
= getw(ascbuf
);
*sp
++ = block(1, op
, t
, 0, getw(ascbuf
));
sp
[-1] = block(2, op
, t
, 0, sp
[-1], getw(ascbuf
));
*sp
++ = block(0, 0, 0, 0);
sp
[-1] = block(1, CBRANCH
, sp
[-1], t
, getw(ascbuf
));
printf("_%s:\n", outname(s
));
printf("_%s:\n~~%s:\n", t
, t
);
error("Binary expression botch");
*sp
++ = block(2, op
, getw(ascbuf
), 0, *--sp
, t
);
sp
[-1] = block(1, op
, getw(ascbuf
), 0, sp
[-1]);
while (c
= getc(ascbuf
)) {
printf("%o", getw(ascbuf
));
if ((o
= getw(ascbuf
)) != 1)