static char *sccsid
="@(#)fort.c 4.8 (Berkeley) 10/15/86";
/* this may force larger trees, etc. */
/* masks for unpacking longs */
# define FOP(x) (int)((x)&0377)
# define VAL(x) (int)(((x)>>8)&0377)
# define REST(x) (((x)>>16)&0177777)
# define FIXINT(x) ((x) == LONG || (x) == ULONG ? (x) - 1 : (x))
# define FIXINT(x) ((x) == SHORT || (x) == USHORT ? (x) + 1 : (x))
FILE * lrd
; /* for default reading routines */
# if !defined(NOLNREAD) && defined(FLEXNAMES)
register char *limit
= &buf
[BUFSIZ
];
if (fread(cp
, sizeof (long), 1, lrd
) != 1)
cerror("intermediate file read error");
cerror("lnread overran string buffer");
if( fread( (char *) &x
, 4, 1, lrd
) <= 0 ) cerror( "intermediate file read error" );
/* if null, opens the standard input */
if( lrd
== NULL
) cerror( "cannot open intermediate file %s", s
);
lcread( cp
, n
) char *cp
; {
if( fread( cp
, 4, n
, lrd
) != n
) cerror( "intermediate file read error" );
lccopy( n
) register n
; {
static char fbuf
[BUFSIZ
];
if( n
> BUFSIZ
/4 ) cerror( "lccopy asked to copy too much" );
if( fread( fbuf
, 4, n
, lrd
) != n
) cerror( "intermediate file read error" );
for( i
=4*n
; fbuf
[i
-1] == '\0' && i
>0; --i
) { /* VOID */ }
if( fwrite( fbuf
, 1, i
, stdout
) != i
) cerror( "output file error" );
/* stack for reading nodes in postfix form */
NODE
** fsp
; /* points to next free position on the stack */
mainp2( argc
, argv
) char *argv
[]; {
files
= p2init( argc
, argv
);
while( files
< argc
&& argv
[files
][0] == '-' ) {
if( files
> argc
) return( nerrors
);
/* read nodes, and go to work... */
if( xdebug
) fprintf( stderr
, "op=%d, val = %d, rest = 0%o\n", FOP(x
), VAL(x
), (int)REST(x
) );
switch( (int)FOP(x
) ){ /* switch on opcode */
fprintf( stderr
, "null opcode ignored\n" );
tmpoff
= baseoff
= lread();
/* beginning of function */
if( baseoff
> maxoff
) maxoff
= baseoff
;
/* maxoff at end of ftn is max of autos and temps
over all blocks in the function */
SETOFF( maxoff
, ALSTACK
);
uerror( "switch not yet done" );
for( x
=VAL(x
); x
>0; --x
) lread();
p
->in
.type
= FIXINT(REST(x
));
else p
->in
.name
[0] = '\0';
if( fsp
>= &fstack
[NSTACKSZ
] ) uerror( "expression depth exceeded" );
p
->in
.type
= FIXINT(REST(x
));
if( VAL(x
) ) p
->tn
.lval
= lread();
p
->in
.type
= FIXINT(REST(x
));
rbusy( p
->tn
.rval
, PTR
| p
->in
.type
);
p
->in
.type
= FIXINT(REST(x
));
rbusy( p
->tn
.rval
, p
->in
.type
);
if( VAL(x
) ) lcread( filename
, VAL(x
) );
if( fsp
== fstack
) continue; /* filename only */
if( --fsp
!= fstack
) uerror( "expression poorly formed" );
if( lflag
) lineid( lineno
, filename
);
if( edebug
) fwalk( p
, eprint
, 0 );
cbgen( 0, (int) REST(x
), 'I' ); /* unconditional branch */
/* otherwise, treat as unary */
* size and alignment come from next long words
p
-> stn
.stsize
= lread();
p
-> stn
.stalign
= lread();
p
->in
.type
= FIXINT(REST(x
));
switch( optype( p
->in
.op
) ){
uerror( "illegal leaf node: %d", p
->in
.op
);