-#ifndef lint
+/*#include <stdio.h> pass2.h*/
+/*#include "config.h" manifest.h*/
+/*#include "mac2defs.h" pass2.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass2.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass2.h"
+/*#include "pcclocal.h" mac2defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)allo.c 4.8 (Berkeley) 1/8/86";
-#endif lint
+#endif
-# include "pass2.h"
+/*# include "pass2.h"*/
NODE resc[3];
int maxa, mina, maxb, minb;
# ifndef ALLO0
-allo0(){ /* free everything */
+int allo0() { /* free everything */
register i;
# endif
# ifndef ALLO
-allo( p, q ) NODE *p; struct optab *q; {
+int allo(p, q) NODE *p; struct optab *q; {
register n, i, j;
int either;
# endif
extern unsigned int offsz;
-freetemp( k ){ /* allocate k integers worth of temp space */
+int freetemp(k) int k; { /* allocate k integers worth of temp space */
/* we also make the convention that, if the number of words is more than 1,
/* it must be aligned for storing doubles... */
# endif
}
-freereg( p, n ) NODE *p; {
+int freereg(p, n) NODE *p; int n; {
/* allocate a register of type n */
/* p gives the type, if floating */
}
# ifndef USABLE
-usable( p, n, r ) NODE *p; {
+int usable(p, n, r) NODE *p; int n; int r; {
/* decide if register r is usable in tree p to satisfy need n */
/* checks, for the moment */
}
# endif
-shareit( p, r, n ) NODE *p; {
+int shareit(p, r, n) NODE *p; int r; int n; {
/* can we make register r available by sharing from p
given that the need is n */
if( (n&(NASL|NBSL)) && ushare( p, 'L', r ) ) return(1);
return(0);
}
-ushare( p, f, r ) NODE *p; {
+int ushare(p, f, r) NODE *p; int f; int r; {
/* can we find a register r to share on the left or right
(as f=='L' or 'R', respectively) of p */
p = getlr( p, f );
return(0);
}
-recl2( p ) register NODE *p; {
+int recl2(p) register NODE *p; {
register r = p->tn.rval;
#ifndef OLD
int op = p->in.op;
int rdebug = 0;
# ifndef RFREE
-rfree( r, t ) TWORD t; {
+int rfree(r, t) int r; TWORD t; {
/* mark register r free, if it is legal to do so */
/* t is the type */
# endif
# ifndef RBUSY
-rbusy(r,t) TWORD t; {
+int rbusy(r, t) int r; TWORD t; {
/* mark register r busy */
/* t is the type */
# endif
# ifndef BUG3
-rwprint( rw ){ /* print rewriting rule */
+int rwprint(rw) int rw; { /* print rewriting rule */
register i, flag;
static char * rwnames[] = {
}
# endif
-reclaim( p, rw, cookie ) NODE *p; {
+int reclaim(p, rw, cookie) NODE *p; int rw; int cookie; {
register NODE **qq;
register NODE *q;
register i;
}
#ifndef ncopy
-XXXncopy( q, p ) NODE *p, *q; {
+int XXXncopy(q, p) NODE *q; NODE *p; {
/* copy the contents of p into q, without any feeling for
the contents */
/* this code assume that copying rval and lval does the job;
}
#endif
-NODE *
-tcopy( p ) register NODE *p; {
+NODE *tcopy(p) register NODE *p; {
/* make a fresh copy of p */
register NODE *q;
return(q);
}
-allchk(){
+int allchk() {
/* check to ensure that all register are free */
register i;
+#include <stdio.h>
+/*#include "config.h" manifest.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass1.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass1.h"
+/*#include "pcclocal.h" macdefs.h*/
+
# define TOKENS 0
# define ERROR 1
# define FREE 2
# define SM 125
# line 146 "cgram.y"
-# include "pass1.h"
+/*# include "pass1.h"*/
#define yyclearin yychar = -1
#define yyerrok yyerrflag = 0
extern int yychar;
# line 899 "cgram.y"
-
-NODE *
-mkty( t, d, s ) unsigned t; {
+NODE *mkty(t, d, s) unsigned t; int d; int s; {
return( block( TYPE, NIL, NIL, t, d, s ) );
}
-NODE *
-bdty( op, p, v ) NODE *p; {
+NODE *bdty(op, p, v) int op; NODE *p; int v; {
register NODE *q;
q = block( op, p, NIL, INT, 0, INT );
return( q );
}
-dstash( n ){ /* put n into the dimension table */
+int dstash(n) int n; { /* put n into the dimension table */
if( curdim >= DIMTABSZ-1 ){
cerror( "dimension table overflow");
}
dimtab[ curdim++ ] = n;
}
-savebc() {
+int savebc() {
if( psavbc > & asavbc[BCSZ-4 ] ){
cerror( "whiles, fors, etc. too deeply nested");
}
flostat = 0;
}
-resetbc(mask){
+int resetbc(mask) int mask; {
swx = *--psavbc;
flostat = *--psavbc | (flostat&mask);
}
-addcase(p) NODE *p; { /* add case to switch */
+int addcase(p) NODE *p; { /* add case to switch */
p = optim( p ); /* change enum to ints */
if( p->in.op != ICON ){
tfree(p);
}
-adddef(){ /* add default case to switch */
+int adddef() { /* add default case to switch */
if( swtab[swx].slab >= 0 ){
uerror( "duplicate default in switch");
return;
deflab( swtab[swx].slab = getlab() );
}
-swstart(){
+int swstart() {
/* begin a switch block */
if( swp >= &swtab[SWITSZ] ){
cerror( "switch table overflow");
++swp;
}
-swend(){ /* end a switch block */
+int swend() { /* end a switch block */
register struct sw *swbeg, *p, *q, *r, *r1;
CONSZ temp;
yyabort:
return(1);
-
case 3: /* no shift yet; clobber input char */
#ifdef YYDEBUG
-#ifndef lint
+#include <stab.h>
+#include <stdio.h>
+/*#include "config.h" manifest.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass1.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass1.h"
+/*#include "pcclocal.h" macdefs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)code.c 1.5 (Berkeley) 8/23/85";
-#endif lint
+#endif
-# include "pass1.h"
-# include <sys/types.h>
-# include <a.out.h>
-# include <stab.h>
+/*# include "pass1.h"*/
+/*# include <sys/types.h>*/
+/*# include <a.out.h>*/
+/*# include <stab.h>*/
int proflg = 0; /* are we generating profiling code? */
int strftn = 0; /* is the current function one which returns a value */
# define putstr(s) fputs((s), stdout)
-branch( n ){
+int branch(n) int n; {
/* output a branch to label n */
/* exception is an ordinary function branching to retlab: then, return */
if( n == retlab && !strftn ){
short log2tab[] = {0, 0, 1, 2, 2, 3, 3, 3, 3};
#define LOG2SZ 9
-defalign(n) {
+int defalign(n) int n; {
/* cause the alignment to become a multiple of n */
n /= SZCHAR;
if( lastloc != PROG && n > 1 ) printf( " .align %d\n", n >= 0 && n < LOG2SZ ? log2tab[n] : 0 );
}
-locctr( l ){
+int locctr(l) int l; {
register temp;
/* l is PROG, ADATA, DATA, STRNG, ISTRNG, or STAB */
return( temp );
}
-deflab( n ){
+int deflab(n) int n; {
/* output something to define the current position as label n */
printf( "L%d:\n", n );
}
int crslab = 10;
-getlab(){
+int getlab() {
/* return a number usable for a label */
return( ++crslab );
}
-
int ent_mask[] = {
0,0,0,0,0, 0xfc0, 0xf80, 0xf00, 0xe00, 0xc00, 0x800, 0};
int reg_use = 11;
-efcode(){
+int efcode() {
/* code for the end of a function */
if( strftn ){ /* copy output (in R2) to caller */
int ftlab1, ftlab2;
-bfcode( a, n ) int a[]; {
+int bfcode(a, n) int a[]; int n; {
/* code for the beginning of a function; a is an array of
indices in stab for the arguments; n is the number */
register i;
fdefflag = 1;
}
-bccode(){ /* called just before the first executable statment */
+int bccode() { /* called just before the first executable statment */
/* by now, the automatics and register variables are allocated */
SETOFF( autooff, SZINT );
/* set aside store area offset */
reg_use = (reg_use > regvar ? regvar : reg_use);
}
-ejobcode( flag ){
+int ejobcode(flag) int flag; {
/* called just before final exit */
/* flag is 1 if errors, 0 if none */
}
-aobeg(){
+int aobeg() {
/* called before removing automatics from stab */
}
-aocode(p) struct symtab *p; {
+int aocode(p) struct symtab *p; {
/* called when automatic p removed from stab */
}
-aoend(){
+int aoend() {
/* called after removing all automatics from stab */
}
-defnam( p ) register struct symtab *p; {
+int defnam(p) register struct symtab *p; {
/* define the current location as the name p->sname */
if( p->sclass == EXTDEF ){
}
-bycode( t, i ){
+int bycode(t, i) int t; int i; {
#ifdef ASSTRINGS
static int lastoctal = 0;
#endif
lastoctal = 0;
printf("\"\n\t.ascii\t\"%c", t );
}
- else
- {
+ else {
lastoctal = 0;
putchar(t);
}
#endif
}
-zecode( n ){
+int zecode(n) int n; {
/* n integer words of zeros */
OFFSZ temp;
if( n <= 0 ) return;
inoff += temp*SZINT;
}
-fldal( t ) unsigned t; { /* return the alignment of field of type t */
+int fldal(t) unsigned t; { /* return the alignment of field of type t */
uerror( "illegal field type" );
return( ALINT );
}
-fldty( p ) struct symtab *p; { /* fix up type of field p */
+int fldty(p) struct symtab *p; { /* fix up type of field p */
;
}
-where(c){ /* print location of error */
+int where(c) int c; { /* print location of error */
/* c is either 'u', 'c', or 'w' */
/* GCOS version */
fprintf( stderr, "%s, line %d: ", ftitle, lineno );
}
-
/* tbl - toreg() returns a pointer to a char string
which is the correct "register move" for the passed type
*/
-struct type_move {TWORD fromtype; char tostrng[8];} toreg_strs[] =
- {
+struct type_move {TWORD fromtype; char tostrng[8];} toreg_strs[] = {
CHAR, "cvtbl",
SHORT, "cvtwl",
INT, "movl",
0, ""
};
-char
-*toreg(type)
- TWORD type;
-{
+char *toreg(type) TWORD type; {
struct type_move *p;
for ( p=toreg_strs; p->fromtype != 0; p++)
}
/* tbl */
-
-main( argc, argv ) char *argv[]; {
+int main(argc, argv) int argc; char *argv[]; {
#ifdef BUFSTDERR
char errbuf[BUFSIZ];
setbuf(stderr, errbuf);
struct sw heapsw[SWITSZ]; /* heap for switches */
-genswitch(p,n) register struct sw *p;{
+int genswitch(p, n) register struct sw *p; int n; {
/* p points to an array of structures, each consisting
of a constant value and a label.
The first is >=0 if there is a default label;
if( p->slab>=0 ) branch( p->slab );
}
-makeheap(p, m, n)
-register struct sw *p;
-{
+int makeheap(p, m, n) register struct sw *p; int m; int n; {
register int q;
q = select(m);
if( q<m ) makeheap(p+q, m-q, 2*n+1);
}
-select(m) {
+int select(m) int m; {
register int l,i,k;
for(i=1; ; i*=2)
return( l + (m-k < l ? m-k : l));
}
-walkheap(start, limit)
-{
+int walkheap(start, limit) int start; int limit; {
int label;
-
if( start > limit ) return;
printf(" cmpl r0,$%d\n", heapsw[start].sval);
printf(" jeql L%d\n", heapsw[start].slab);
+#include <gen.h>
+#include <stdio.h>
+/*#include <strings.h> gen.h*/
+#ifdef __STDC__
+#include <stdarg.h>
+#define _va_start(argp, arg) va_start(argp, arg)
+#else
+#include <varargs.h>
+#define _va_start(argp, arg) va_start(argp)
+#endif
+/*#include "config.h" manifest.h*/
+/*#include "manifest.h" pass1.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass1.h"
+/*#include "pcclocal.h" manifest.h*/
+
/* common.c 4.2 85/08/22 */
-#include <varargs.h>
+/*#include <varargs.h>*/
/*#ifdef PASS1COMMON*/
-#include "pass1.h"
+/*#include "pass1.h"*/
/*#else*/
/*#ifdef PASS2COMMON*/
/*#include "pass2.h"*/
extern unsigned int offsz;
-unsigned caloff(){
+unsigned caloff() {
register i;
unsigned int temp;
unsigned int off;
NODE *lastfree; /* pointer to last free node; (for allocator) */
-uerror( s, va_alist ) char *s; va_dcl { /* nonfatal error message */
+#ifdef __STDC__
+int uerror(char *s, ...)
+#else
+int uerror(s, va_alist) char *s; va_dcl
+#endif
+{ /* nonfatal error message */
va_list argp;
/* the routine where is different for pass 1 and pass 2;
++nerrors;
where('u');
- va_start(argp);
+ _va_start(argp, fmt);
vfprintf( stderr, s, argp );
va_end(argp);
fprintf( stderr, "\n" );
if( nerrors > 30 ) cerror( "too many errors");
}
-cerror( s, va_alist ) char *s; va_dcl { /* compiler error: die */
+#ifdef __STDC__
+int cerror(char *s, ...)
+#else
+int cerror(s, va_alist) char *s; va_dcl
+#endif
+{ /* compiler error: die */
va_list argp;
where('c');
}
else {
fprintf( stderr, "compiler error: " );
- va_start(argp);
+ _va_start(argp, fmt);
fprintf( stderr, s, argp );
va_end(argp);
fprintf( stderr, "\n" );
int Wflag = 0; /* Non-zero means do not print warnings */
-werror( s, va_alist ) char *s; va_dcl { /* warning */
+#ifdef __STDC__
+int werror(char *s, ...)
+#else
+int werror(s, va_alist) char *s; va_dcl
+#endif
+{ /* warning */
va_list argp;
if(Wflag) return;
where('w');
fprintf( stderr, "warning: " );
- va_start(argp);
+ _va_start(argp, fmt);
fprintf( stderr, s, argp );
va_end(argp);
fprintf( stderr, "\n" );
#endif
}
-tinit(){ /* initialize expression tree search */
+int tinit() { /* initialize expression tree search */
register NODE *p;
# define TNEXT(p) (p== &node[TREESZ-1]?node:p+1)
-NODE *
-talloc(){
+NODE *talloc() {
register NODE *p, *q;
q = lastfree;
/* NOTREACHED */
}
-tcheck(){ /* ensure that all nodes have been freed */
+int tcheck() { /* ensure that all nodes have been freed */
register NODE *p;
freetstr();
#endif
}
-tfree( p ) NODE *p; {
+int tfree(p) NODE *p; {
/* free the tree p */
extern tfree1();
}
-tfree1(p) NODE *p; {
+int tfree1(p) NODE *p; {
if( p == 0 ) cerror( "freeing blank tree!");
else p->in.op = FREE;
}
-fwalk( t, f, down ) register NODE *t; int (*f)(); {
+int fwalk(t, f, down) register NODE *t; int (*f)(); int down; {
int down1, down2;
}
#ifndef vax
-walkf( t, f ) register NODE *t; int (*f)(); {
+int walkf(t, f) register NODE *t; int (*f)(); {
register opty;
opty = optype(t->in.op);
* Deliberately avoids recursion -- use this version on machines with
* expensive procedure calls.
*/
-walkf(t, f)
- register NODE *t;
- register int (*f)();
-{
+int walkf(t, f) register NODE *t; register int (*f)(); {
register int i = 1;
register int opty = optype(t->in.op);
static NODE *at[NR];
#undef POP
#endif
-
-
int dope[ DSIZE ];
char *opst[DSIZE];
-1, "", 0
};
-mkdope(){
+int mkdope() {
register struct dopest *q;
for( q = indope; q->dopeop >= 0; ++q ){
}
}
# ifndef BUG4
-tprint( t ) TWORD t; { /* output a nice description of the type of t */
+int tprint(t) TWORD t; { /* output a nice description of the type of t */
static char * tnames[] = {
"undef",
char **curtstr = tstrbuf;
int tstrused;
-char *
-tstr(cp)
- register char *cp;
-{
+char *tstr(cp) register char *cp; {
register int i = strlen(cp);
register char *dp;
+#ifndef _CONFIG_H_
+#define _CONFIG_H_
+
/* config.h 4.3 85/08/22 */
-#ifndef _CONFIG_
-#define _CONFIG_
+/*#ifndef _CONFIG_*/
+/*#define _CONFIG_*/
/*
* Compiler configuration definitions.
*/
#ifndef FLEXNAMES
#define NCHNAM 8 /* significant chars of identifier */
#endif
+/*#endif*/
+
#endif
-#ifndef lint
+/*#include <stdio.h> pass2.h*/
+/*#include "config.h" manifest.h*/
+/*#include "mac2defs.h" pass2.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass2.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass2.h"
+/*#include "pcclocal.h" mac2defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)fort.c 4.7 (Berkeley) 8/22/85";
-#endif lint
+#endif
# ifndef FORT
# define FORT
/* this may force larger trees, etc. */
# endif
-# include "pass2.h"
+/*# include "pass2.h"*/
# include "fort.h"
/* masks for unpacking longs */
# ifndef NOLNREAD
#ifdef FLEXNAMES
-char *
-lnread()
-{
+char *lnread() {
char buf[BUFSIZ];
register char *cp = buf;
register char *limit = &buf[BUFSIZ];
return (tstr(buf));
}
#endif
-# endif NOLNREAD
+# endif
# ifndef NOLREAD
-long lread(){
+long lread() {
static long x;
if( fread( (char *) &x, 4, 1, lrd ) <= 0 ) cerror( "intermediate file read error" );
return( x );
# endif
# ifndef NOLOPEN
-lopen( s ) char *s; {
+int lopen(s) char *s; {
/* if null, opens the standard input */
if( *s ){
lrd = fopen( s, "r" );
# endif
# ifndef NOLCREAD
-lcread( cp, n ) char *cp; {
+int lcread(cp, n) char *cp; int n; {
if( n > 0 ){
if( fread( cp, 4, n, lrd ) != n ) cerror( "intermediate file read error" );
}
# endif
# ifndef NOLCCOPY
-lccopy( n ) register n; {
+int lccopy(n) register n; {
register i;
static char fbuf[BUFSIZ];
if( n > 0 ){
NODE ** fsp; /* points to next free position on the stack */
unsigned int offsz;
-unsigned int caloff();
-mainp2( argc, argv ) char *argv[]; {
+/*unsigned int caloff();*/
+int mainp2(argc, argv) int argc; char *argv[]; {
int files;
register long x;
register NODE *p;
+#ifndef _FORT_H_
+#define _FORT_H_
+
+/*#include <stdio.h> pass2.h*/
+#include "pass2.h"
+
/* fort.h 4.1 85/03/19 */
/* machine dependent file */
-label( n ){
+int label(n) int n; {
printf( "L%d:\n", n );
}
-tlabel(){
+int tlabel() {
lccopy( 2 );
printf( ":\n" );
}
+
+#endif
-#ifndef lint
+#include <math.h>
+#include <stdio.h>
+/*#include "config.h" manifest.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass1.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass1.h"
+/*#include "pcclocal.h" macdefs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)local.c 1.8 (Berkeley) 8/23/85";
-#endif lint
+#endif
-# include "pass1.h"
+/*# include "pass1.h"*/
/* this file contains code which is dependent on the target machine */
-NODE *
-cast( p, t ) register NODE *p; TWORD t; {
+NODE *cast(p, t) register NODE *p; TWORD t; {
/* cast node p to type t */
p = buildtree( CAST, block( NAME, NIL, NIL, t, 0, (int)t ), p );
return( p->in.right );
}
-NODE *
-clocal(p) NODE *p; {
+NODE *clocal(p) NODE *p; {
/* this is called to do local transformations on
an expression tree preparitory to its being
return(p);
}
-andable( p ) NODE *p; {
+int andable(p) NODE *p; {
return(1); /* all names can have & taken on them */
}
-cendarg(){ /* at the end of the arguments of a ftn, set the automatic offset */
+int cendarg() { /* at the end of the arguments of a ftn, set the automatic offset */
autooff = AUTOINIT;
}
-cisreg( t ) TWORD t; { /* is an automatic variable of type t OK for a register variable */
+int cisreg(t) TWORD t; { /* is an automatic variable of type t OK for a register variable */
#ifdef TRUST_REG_CHAR_AND_REG_SHORT
if( t==INT || t==UNSIGNED || t==LONG || t==ULONG /* tbl */
return(0);
}
-NODE *
-offcon( off, t, d, s ) OFFSZ off; TWORD t; {
+NODE *offcon(off, t, d, s) OFFSZ off; TWORD t; int d; int s; {
/* return a node, for structure references, which is suitable for
being added to a pointer of type t, in order to be off bits offset
}
-
static inwd /* current bit offsed in word */;
static word /* word being built from fields */;
-incode( p, sz ) register NODE *p; {
+int incode(p, sz) register NODE *p; int sz; {
/* generate initialization code for assigning a constant c
to a field of width sz */
}
}
-fincode( d, sz ) double d; {
+int fincode(d, sz) double d; int sz; {
/* output code to initialize space of size sz to the value d */
/* the proper alignment has been obtained */
/* inoff is updated to have the proper final value */
/* on the target machine, write it out in octal! */
-
printf(" %s 0%c%.20e\n", sz == SZDOUBLE ? ".double" : ".float",
sz == SZDOUBLE ? 'd' : 'f', d);
inoff += sz;
}
-cinit( p, sz ) NODE *p; {
+int cinit(p, sz) NODE *p; int sz; {
NODE *l;
/*
inoff += sz;
}
-vfdzero( n ){ /* define n bits of zeros in a vfd */
+int vfdzero(n) int n; { /* define n bits of zeros in a vfd */
if( n <= 0 ) return;
}
}
-char *
-exname( p ) char *p; {
+char *exname(p) char *p; {
/* make a name look like an external name in the local machine */
#ifndef FLEXNAMES
return( text );
}
-ctype( type ) TWORD type;
+int ctype(type) TWORD type;
{ /* map types which are not defined on the local machine */
switch( BTYPE(type) ){
return( type );
}
-noinit() { /* curid is a variable which is defined but
+int noinit() { /* curid is a variable which is defined but
is not initialized (and not a function );
This routine returns the stroage class for an uninitialized declaration */
}
-commdec( id ){ /* make a common declaration for id, if reasonable */
+int commdec(id) int id; { /* make a common declaration for id, if reasonable */
register struct symtab *q;
OFFSZ off, tsize();
printf( "\n" );
}
-isitlong( cb, ce ){ /* is lastcon to be long or short */
+int isitlong(cb, ce) int cb; int ce; { /* is lastcon to be long or short */
/* cb is the first character of the representation, ce the last */
if( ce == 'l' || ce == 'L' ||
return(0);
}
-
-isitfloat( s ) char *s; {
+int isitfloat(s) char *s; {
union cvt {
double d;
int n[2];
return( DCON );
}
-ecode( p ) NODE *p; {
+int ecode(p) NODE *p; {
/* walk the tree and write out the nodes.. */
}
#ifndef ONEPASS
-tlen(p) NODE *p;
-{
+int tlen(p) NODE *p; {
switch(p->in.type) {
case CHAR:
case UCHAR:
-# ifndef lint
+#include <ctype.h>
+/*#include <stdio.h> pass2.h*/
+#include <strings.h>
+/*#include "config.h" manifest.h*/
+/*#include "mac2defs.h" pass2.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass2.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass2.h"
+/*#include "pcclocal.h" mac2defs.h*/
+
+# if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)local2.c 1.14 (Berkeley) 4/23/86";
# endif
-# include "pass2.h"
-# include "ctype.h"
+/*# include "pass2.h"*/
+/*# include "ctype.h"*/
# ifdef FORT
int ftlab1, ftlab2;
# endif
# define BITMASK(n) ((1L<<n)-1)
-where2(c){
+int where2(c) int c; {
fprintf( stderr, "%s, line %d: ", ftitle, lineno );
}
-lineid( l, fn ) char *fn; {
+int lineid(l, fn) int l; char *fn; {
/* identify line l and file fn */
printf( "# line %d, file %s\n", l, fn );
}
-
-eobl2(){
+int eobl2() {
OFFSZ spoff; /* offset from stack pointer */
#ifdef FORT
spoff = maxoff;
AND, "bic",
-1, "" };
-hopcode( f, o ){
+int hopcode(f, o) int f; int o; {
/* output the appropriate string from the above table */
register struct hoptab *q;
};
-tlen(p) NODE *p;
-{
+int tlen(p) NODE *p; {
switch(p->in.type) {
case CHAR:
case UCHAR:
}
}
-mixtypes(p, q) NODE *p, *q;
-{
+int mixtypes(p, q) NODE *p; NODE *q; {
register TWORD tp, tq;
tp = p->in.type;
(tq==FLOAT || tq==DOUBLE) );
}
-prtype(n) NODE *n;
-{
- switch (n->in.type)
- {
+int prtype(n) NODE *n; {
+ switch (n->in.type) {
case DOUBLE:
putchar('d');
return;
}
}
-zzzcode( p, c ) register NODE *p; {
+int zzzcode(p, c) register NODE *p; int c; {
register m;
CONSZ val;
switch( c ){
cbgen( p->in.op, p->bn.label, c );
return;
- case 'A':
- {
+ case 'A': {
register NODE *l, *r;
if (x2debug) e2print(p, 0, &val, &val);
}
#else
prtype(l);
-#endif FORT
+#endif
goto ops;
}
else if (tlen(l) > tlen(r) && ISUNSIGNED(r->in.type))
return;
}
- case 'G': /* i *= f; asgops with int lhs and float rhs */
- {
+ case 'G': /* i *= f; asgops with int lhs and float rhs */ {
register NODE *l, *r, *s;
int rt;
return;
}
- case 'B': /* get oreg value in temp register for left shift */
- {
+ case 'B': /* get oreg value in temp register for left shift */ {
register NODE *r;
if (x2debug) e2print(p, 0, &val, &val);
r = p->in.right;
return;
}
- case 'C': /* num words pushed on arg stack */
- {
+ case 'C': /* num words pushed on arg stack */ {
extern int gc_numbytes;
extern int x2debug;
putchar('\t');
case 'E': /* INCR and DECR, FOREFF */
- if (p->in.right->tn.lval == 1)
- {
+ if (p->in.right->tn.lval == 1) {
putstr( p->in.op == INCR ? "inc" : "dec" );
prtype(p->in.left);
putchar('\t');
adrput(p->in.left);
return;
- case 'F': /* register type of right operand */
- {
+ case 'F': /* register type of right operand */ {
register NODE *n;
extern int x2debug;
register int ty;
}
case 'L': /* type of left operand */
- case 'R': /* type of right operand */
- {
+ case 'R': /* type of right operand */ {
register NODE *n;
extern int x2debug;
printf("$%d", 32 - p->in.right->tn.lval );
return;
- case 'T': /* rounded structure length for arguments */
- {
+ case 'T': /* rounded structure length for arguments */ {
int size;
size = p->stn.stsize;
return;
}
- case 'S': /* structure assignment */
- {
+ case 'S': /* structure assignment */ {
register NODE *l, *r;
register size;
* that will do the job correctly; otherwise return 0. Note that
* a register must always end up having type INT or UNSIGNED.
*/
-int
-collapsible(dest, src)
-NODE *dest, *src;
-{
+int collapsible(dest, src) NODE *dest; NODE *src; {
int st = src->in.type;
int dt = dest->in.type;
int newt = 0;
return (newt);
}
-rmove( rt, rs, t ) TWORD t; {
+int rmove(rt, rs, t) int rt; int rs; TWORD t; {
printf( " %s %s,%s\n",
#ifdef FORT
!Oflag ? (t==DOUBLE ? "movq" : "movl") :
INTEMP, INTAREG|INAREG|INTBREG|INBREG|SOREG|STARREG|STARNM,
0, 0 };
-setregs(){ /* set up temporary registers */
+int setregs() { /* set up temporary registers */
fregs = 6; /* tbl- 6 free regs on VAX (0-5) */
;
}
-rewfld( p ) NODE *p; {
+int rewfld(p) NODE *p; {
return(1);
}
-callreg(p) NODE *p; {
+int callreg(p) NODE *p; {
return( R0 );
}
-base( p ) register NODE *p; {
+int base(p) register NODE *p; {
register int o = p->in.op;
if( (o==ICON && p->in.name[0] != '\0')) return( 100 ); /* ie no base reg */
return( -1 );
}
-offset( p, tyl ) register NODE *p; int tyl; {
+int offset(p, tyl) register NODE *p; int tyl; {
if( tyl==1 &&
p->in.op==REG &&
return( -1 );
}
-makeor2( p, q, b, o) register NODE *p, *q; register int b, o; {
+int makeor2(p, q, b, o) register NODE *p; register NODE *q; register int b; register int o; {
register NODE *t;
register int i;
NODE *f;
return;
}
-canaddr( p ) NODE *p; {
+int canaddr(p) NODE *p; {
register int o = p->in.op;
if( o==NAME || o==REG || o==ICON || o==OREG || (o==UNARY MUL && shumul(p->in.left)) ) return(1);
return(0);
}
-flshape( p ) register NODE *p; {
+int flshape(p) register NODE *p; {
return( p->in.op == REG || p->in.op == NAME || p->in.op == ICON ||
(p->in.op == OREG && (!R2TEST(p->tn.rval) || tlen(p) == 1)) );
}
-shtemp( p ) register NODE *p; {
+int shtemp(p) register NODE *p; {
if( p->in.op == STARG ) p = p->in.left;
return( p->in.op==NAME || p->in.op ==ICON || p->in.op == OREG || (p->in.op==UNARY MUL && shumul(p->in.left)) );
}
-shumul( p ) register NODE *p; {
+int shumul(p) register NODE *p; {
register o;
extern int x2debug;
printf(" prname=%s,plty=%d, prlval=%D\n", p->in.right->in.name, p->in.left->in.type, p->in.right->tn.lval);
}
-
o = p->in.op;
if( o == NAME || (o == OREG && !R2TEST(p->tn.rval)) || o == ICON ) return( STARNM );
if( ( o == INCR || o == ASG MINUS ) &&
( p->in.left->in.op == REG && p->in.right->in.op == ICON ) &&
- p->in.right->in.name[0] == '\0' )
- {
- switch (p->in.type)
- {
+ p->in.right->in.name[0] == '\0' ) {
+ switch (p->in.type) {
case CHAR|PTR:
case UCHAR|PTR:
o = 1;
return( 0 );
}
-adrcon( val ) CONSZ val; {
+int adrcon(val) CONSZ val; {
putchar( '$' );
printf( CONFMT, val );
}
-conput( p ) register NODE *p; {
+int conput(p) register NODE *p; {
switch( p->in.op ){
case ICON:
}
}
-insput( p ) register NODE *p; {
+int insput(p) register NODE *p; {
cerror( "insput" );
}
-upput( p ) register NODE *p; {
+int upput(p) register NODE *p; {
cerror( "upput" );
}
-adrput( p ) register NODE *p; {
+int adrput(p) register NODE *p; {
register int r;
/* output an address, with offsets, from p */
}
-acon( p ) register NODE *p; { /* print out a constant */
+int acon(p) register NODE *p; { /* print out a constant */
if( p->in.name[0] == '\0' ){
printf( CONFMT, p->tn.lval);
}
*/
-genscall( p, cookie ) register NODE *p; {
+int genscall(p, cookie) register NODE *p; int cookie; {
/* structure valued call */
return( gencall( p, cookie ) );
}
int gc_numbytes;
/* tbl */
-gencall( p, cookie ) register NODE *p; {
+int gencall(p, cookie) register NODE *p; int cookie; {
/* generate the call given by p */
register NODE *p1;
register temp, temp1;
};
/* tbl */
-cbgen( o, lab, mode ) { /* printf conditional and unconditional branches */
+int cbgen(o, lab, mode) int o; int lab; int mode; { /* printf conditional and unconditional branches */
/* tbl */
if( o == 0 ) printf( " jbr L%d\n", lab );
}
}
-nextcook( p, cookie ) NODE *p; {
+int nextcook(p, cookie) NODE *p; int cookie; {
/* we have failed to match p with cookie; try another */
if( cookie == FORREW ) return( 0 ); /* hopeless! */
if( !(cookie&(INTAREG|INTBREG)) ) return( INTAREG|INTBREG );
return( FORREW );
}
-lastchance( p, cook ) NODE *p; {
+int lastchance(p, cook) NODE *p; int cook; {
/* forget it! */
return(0);
}
-optim2( p ) register NODE *p; {
+int optim2(p) register NODE *p; {
/* do local tree transformations and optimizations */
register NODE *l, *r;
}
}
-NODE * addroreg(l) NODE *l;
+NODE *addroreg(l) NODE *l;
/* OREG was built in clocal()
* for an auto or formal parameter
* now its address is being taken
* local code must unwind it
* back to PLUS/MINUS REG ICON
* according to local conventions
- */
-{
+ */ {
cerror("address of OREG taken");
/*NOTREACHED*/
}
-
-
# ifndef ONEPASS
-main( argc, argv ) char *argv[]; {
+int main(argc, argv) int argc; char *argv[]; {
return( mainp2( argc, argv ) );
}
# endif
-
/* added by jwf */
struct functbl {
int fop;
ASG MOD, TANY, "aurem",
0, 0, 0 };
-hardops(p) register NODE *p; {
+int hardops(p) register NODE *p; {
/* change hard to do operators into function calls. */
register NODE *q;
register struct functbl *f;
}
-zappost(p) NODE *p; {
+int zappost(p) NODE *p; {
/* look for ++ and -- operators and remove them */
register o, ty;
if( ty != LTYPE ) zappost( p->in.left );
}
-fixpre(p) NODE *p; {
+int fixpre(p) NODE *p; {
register o, ty;
o = p->in.op;
if( ty != LTYPE ) fixpre( p->in.left );
}
-strip(p) register NODE *p; {
+int strip(p) register NODE *p; {
NODE *q;
/* strip nodes off the top when no side effects occur */
}
}
-myreader(p) register NODE *p; {
+int myreader(p) register NODE *p; {
strip( p ); /* strip off operations with no side effects */
canon( p ); /* expands r-vals for fields */
walkf( p, hardops ); /* convert ops to function calls */
+#ifndef _MAC2DEFS_H_
+#define _MAC2DEFS_H_
+
+#include "pcclocal.h"
+
/* mac2defs.h 4.2 85/08/23 */
/*
/*#define ncopy(q, p) ((q)->in = (p)->in)*/
#define MYREADER(p) myreader(p)
-int optim2();
+/*int optim2();*/
/* This indicates there are no additional special shapes, see match.c */
#define special(a, b) 0
+
+#endif
+#ifndef _MACDEFS_H_
+#define _MACDEFS_H_
+
+#include "pcclocal.h"
+
/* macdefs.h 4.2 85/08/23 */
-#ifndef _MACDEFS_
-#define _MACDEFS_
+/*#ifndef _MACDEFS_*/
+/*#define _MACDEFS_*/
#define makecc(val,i) lastcon = (lastcon<<8)|((val<<24)>>24);
/*#ifndef ncopy*/
#define ncopy(q, p) ((q)->in = (p)->in)
/*#endif*/
+/*#endif*/
+
#endif
+#ifndef _MANIFEST_H_
+#define _MANIFEST_H_
+
+/*#include "config.h" ndu.h*/
+#include "ndu.h"
+/*#include "pcclocal.h" ndu.h*/
+
/* manifest.h 4.1 85/03/19 */
-#ifndef _MANIFEST_
-#define _MANIFEST_
+/*#ifndef _MANIFEST_*/
+/*#define _MANIFEST_*/
-#include <stdio.h>
-#include "pcclocal.h"
-#include "config.h"
+/*#include <stdio.h>*/
+/*#include "pcclocal.h"*/
+/*#include "config.h"*/
#define DSIZE (MAXOP+1) /* DSIZE is the size of the dope array */
* External declarations, typedefs and the like
*/
#ifdef FLEXNAMES
-char *hash();
-char *savestr();
-char *tstr();
+/*char *hash();*/
+/*char *savestr();*/
+/*char *tstr();*/
extern int tstrused;
extern char *tstrbuf[];
extern char **curtstr;
extern int dope[]; /* a vector containing operator information */
extern char *opst[]; /* a vector containing names for ops */
+/*#endif*/
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* comm1.c */
+unsigned caloff __P((void));
+int uerror __P((char *s, ...));
+int cerror __P((char *s, ...));
+int werror __P((char *s, ...));
+int tinit __P((void));
+NODE *talloc __P((void));
+int tcheck __P((void));
+int tfree __P((NODE *p));
+int tfree1 __P((NODE *p));
+int fwalk __P((register NODE *t, int (*f)(void), int down));
+int walkf __P((register NODE *t, int (*f)(void)));
+int walkf __P((register NODE *t, register int (*f)(void)));
+int mkdope __P((void));
+int tprint __P((TWORD t));
+char *tstr __P((register char *cp));
+
#endif
-#ifndef lint
+/*#include <stdio.h> pass2.h*/
+/*#include "mac2defs.h" pass2.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass2.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass2.h"
+/*#include "pcclocal.h" mac2defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)match.c 4.4 (Berkeley) 8/22/85";
-#endif lint
+#endif
-# include "pass2.h"
+/*# include "pass2.h"*/
# ifdef WCARD1
# ifdef WCARD2
int sdebug = 0;
-tshape( p, shape ) NODE *p; {
+int tshape(p, shape) NODE *p; int shape; {
/* return true if shape is appropriate for the node p
side effect for SFLD is to set up fldsz,etc */
register o, mask;
int t2debug = 0;
-ttype( t, tword ) TWORD t; {
+int ttype(t, tword) TWORD t; int tword; {
/* does the type t match tword */
if( tword & TANY ) return(1);
struct optab *opptr[DSIZE];
-setrew(){
+int setrew() {
/* set rwtable to first value which allows rewrite */
register struct optab *q;
register int i;
}
cerror( "bad setrew" );
-
more:
for( i=0; i<DSIZE; ++i ){
if( dope[i] ){ /* there is an op... */
}
}
-match( p, cookie ) NODE *p; {
+int match(p, cookie) NODE *p; int cookie; {
/* called by: order, gencall
look for match in table and generate code if found unless
entry specified REWRITE.
int rtyflg = 0;
-expand( p, cookie, cp ) NODE *p; register char *cp; {
+int expand(p, cookie, cp) NODE *p; int cookie; register char *cp; {
/* generate code by interpreting table entry */
# ifdef NEWZZZ
}
-NODE *
-getlr( p, c ) NODE *p; {
+NODE *getlr(p, c) NODE *p; int c; {
/* return the pointer to the left or right side of p, or p itself,
depending on the optype of p */
NODE * ststack[MLSZ];
NODE **stp; /* pointing into ststack */
-mlinit(){
+int mlinit() {
union mltemplate **lastlink;
register union mltemplate *n;
register mlop;
# endif
}
-mlmatch( subtree, target, subtarget ) NODE * subtree; int target,subtarget;{
+int mlmatch(subtree, target, subtarget) NODE *subtree; int target; int subtarget; {
/*
* does subtree match a multi-level tree with
* tag "target"? Return zero on failure,
+#ifndef _NDU_H_
+#define _NDU_H_
+
+#include "config.h"
+#include "macdefs.h"
+
/* ndu.h 4.1 85/03/19 */
/*
float fval;
} fpn;
};
+
+#endif
-#ifndef lint
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass1.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass1.h"
+/*#include "pcclocal.h" macdefs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)optim.c 4.7 (Berkeley) 1/8/86";
-#endif lint
+#endif
-# include "pass1.h"
+/*# include "pass1.h"*/
# define SWAP(p,q) {sp=p; p=q; q=sp;}
# define RCON(p) (p->in.right->in.op==ICON)
int oflag = 0;
-NODE *
-fortarg( p ) NODE *p; {
+NODE *fortarg(p) NODE *p; {
/* fortran function arguments */
if( p->in.op == CM ){
/* mapping relationals when the sides are reversed */
short revrel[] ={ EQ, NE, GE, GT, LE, LT, UGE, UGT, ULE, ULT };
-NODE *
-optim(p) register NODE *p; {
+NODE *optim(p) register NODE *p; {
/* local optimizations, most of which are probably machine independent */
register o, ty;
return(p);
}
-ispow2( c ) CONSZ c; {
+int ispow2(c) CONSZ c; {
register i;
if( c <= 0 || (c&(c-1)) ) return(-1);
for( i=0; c>1; ++i) c >>= 1;
-#ifndef lint
+/*#include <stdio.h> pass2.h*/
+/*#include "mac2defs.h" pass2.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass2.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass2.h"
+/*#include "pcclocal.h" mac2defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)order.c 1.7 (Berkeley) 1/8/86";
-#endif lint
+#endif
-# include "pass2.h"
+/*# include "pass2.h"*/
int maxargs = { -1 };
-stoasg( p, o ) register NODE *p; {
+int stoasg(p, o) register NODE *p; int o; {
/* should the assignment op p be stored,
given that it lies as the right operand of o
(or the left, if o==UNARY MUL) */
*/
}
-deltest( p ) register NODE *p; {
+int deltest(p) register NODE *p; {
/* should we delay the INCR or DECR operation p */
p = p->in.left;
return( p->in.op == REG || p->in.op == NAME || p->in.op == OREG );
}
-autoincr( p ) NODE *p; {
+int autoincr(p) NODE *p; {
register NODE *q = p->in.left;
if( q->in.op == INCR && q->in.left->in.op == REG &&
return(0);
}
-mkadrs(p) register NODE *p; {
+int mkadrs(p) register NODE *p; {
register o;
o = p->in.op;
}
}
-notoff( t, r, off, cp) TWORD t; CONSZ off; char *cp; {
+int notoff(t, r, off, cp) TWORD t; int r; CONSZ off; char *cp; {
/* is it legal to make an OREG or NAME entry which has an
/* offset of off, (from a register of r), if the
/* resulting thing had type t */
# define max(x,y) ((x)<(y)?(y):(x))
-sucomp( p ) register NODE *p; {
+int sucomp(p) register NODE *p; {
/* set the su field in the node to the sethi-ullman
number, or local equivalent */
}
}
-
/* If rhs needs n, lhs needs m, regular su computation */
sul = p->in.left->in.su;
int radebug = 0;
-rallo( p, down ) NODE *p; {
+int rallo(p, down) NODE *p; int down; {
/* do register allocation */
register o, type, down1, down2, ty;
ty = optype( o = p->in.op );
type = p->in.type;
-
if( type == DOUBLE || type == FLOAT ){
if( o == FORCE ) down1 = R0|MUSTDO;
}
}
-offstar( p ) register NODE *p; {
+int offstar(p) register NODE *p; {
if( p->in.op == PLUS ) {
if( p->in.left->in.su == fregs ) {
order( p->in.left, INTAREG|INAREG );
order( p, INTAREG|INAREG );
}
-setincr( p ) register NODE *p; {
+int setincr(p) register NODE *p; {
p = p->in.left;
if( p->in.op == UNARY MUL ){
offstar( p );
return( 0 );
}
-setbin( p ) register NODE *p; {
+int setbin(p) register NODE *p; {
register ro, rt;
rt = p->in.right->in.type;
return(0);
}
-setstr( p ) register NODE *p; { /* structure assignment */
+int setstr(p) register NODE *p; { /* structure assignment */
if( p->in.right->in.op != REG ){
order( p->in.right, INTAREG );
return(1);
return( 0 );
}
-setasg( p ) register NODE *p; {
+int setasg(p) register NODE *p; {
/* setup for assignment operator */
if( !canaddr(p->in.right) ) {
return(0);
}
-setasop( p ) register NODE *p; {
+int setasop(p) register NODE *p; {
/* setup for =ops */
register rt, ro;
}
*/
-
p = p->in.left;
if( p->in.op == FLD ) p = p->in.left;
int crs2lab = 99999; /* VAX */
-get2lab(){
+int get2lab() {
return( crs2lab-- );
}
-def2lab( l ){
+int def2lab(l) int l; {
printf( "L%d:\n", l );
}
-genargs( p ) register NODE *p; {
+int genargs(p) register NODE *p; {
register NODE *pasg;
register align;
register size;
order( p, FORARG );
}
-argsize( p ) register NODE *p; {
+int argsize(p) register NODE *p; {
register t;
t = 0;
if( p->in.op == CM ){
+#ifndef _PASS1_H_
+#define _PASS1_H_
+
+/*#include "config.h" manifest.h*/
+/*#include "macdefs.h" manifest.h*/
+#include "manifest.h"
+/*#include "ndu.h" manifest.h*/
+
/* pass1.h 4.2 85/08/22 */
-#ifndef _PASS1_
-#define _PASS1_
+/*#ifndef _PASS1_*/
+/*#define _PASS1_*/
-#include "macdefs.h"
-#include "manifest.h"
-#include "ndu.h"
+/*#include "macdefs.h"*/
+/*#include "manifest.h"*/
+/*#include "ndu.h"*/
/*
* Symbol table definition.
#define FIELD 0100
#define FLDSIZ 077
#ifndef BUG1
-extern char *scnames();
+/*extern char *scnames();*/
#endif
/*
*clocal();
OFFSZ tsize(),
psize();
-TWORD types();
-double atof();
-char *exname(), *exdcon();
+/*TWORD types();*/
+/*double atof();*/
+/*char *exname(), *exdcon();*/
#define checkst(x)
/* see pass2.h for the complete set of bits that can be on in the same word */
#define NOPREF 020000 /* no preference for register assignment */
+/*#endif*/
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* cgram.c */
+NODE *mkty __P((unsigned t, int d, int s));
+NODE *bdty __P((int op, NODE *p, int v));
+int dstash __P((int n));
+int savebc __P((void));
+int resetbc __P((int mask));
+int addcase __P((NODE *p));
+int adddef __P((void));
+int swstart __P((void));
+int swend __P((void));
+int yyparse __P((void));
+
+/* code.c */
+int branch __P((int n));
+int defalign __P((int n));
+int locctr __P((int l));
+int deflab __P((int n));
+int getlab __P((void));
+int efcode __P((void));
+int bfcode __P((int a[], int n));
+int bccode __P((void));
+int ejobcode __P((int flag));
+int aobeg __P((void));
+int aocode __P((struct symtab *p));
+int aoend __P((void));
+int defnam __P((register struct symtab *p));
+int bycode __P((int t, int i));
+int zecode __P((int n));
+int fldal __P((unsigned t));
+int fldty __P((struct symtab *p));
+int where __P((int c));
+char *toreg __P((TWORD type));
+int main __P((int argc, char *argv[]));
+int genswitch __P((register struct sw *p, int n));
+int makeheap __P((register struct sw *p, int m, int n));
+int select __P((int m));
+int walkheap __P((int start, int limit));
+
+/* local.c */
+NODE *cast __P((register NODE *p, TWORD t));
+NODE *clocal __P((NODE *p));
+int andable __P((NODE *p));
+int cendarg __P((void));
+int cisreg __P((TWORD t));
+NODE *offcon __P((OFFSZ off, TWORD t, int d, int s));
+int incode __P((register NODE *p, int sz));
+int fincode __P((double d, int sz));
+int cinit __P((NODE *p, int sz));
+int vfdzero __P((int n));
+char *exname __P((char *p));
+int ctype __P((TWORD type));
+int noinit __P((void));
+int commdec __P((int id));
+int isitlong __P((int cb, int ce));
+int isitfloat __P((char *s));
+int ecode __P((NODE *p));
+int tlen __P((NODE *p));
+
+/* optim.c */
+NODE *fortarg __P((NODE *p));
+NODE *optim __P((register NODE *p));
+int ispow2 __P((CONSZ c));
+
+/* pftn.c */
+int defid __P((register NODE *q, register int class));
+int psave __P((int i));
+int ftnend __P((void));
+int dclargs __P((void));
+NODE *rstruct __P((int idn, int soru));
+int moedef __P((int idn));
+int bstruct __P((int idn, int soru));
+NODE *dclstruct __P((int oparam));
+int yyerror __P((char *s));
+int yyaccpt __P((void));
+int ftnarg __P((int idn));
+int talign __P((register unsigned ty, register s));
+OFFSZ tsize __P((TWORD ty, int d, int s));
+int inforce __P((OFFSZ n));
+int vfdalign __P((int n));
+int beginit __P((int curid));
+int instk __P((int id, TWORD t, int d, int s, OFFSZ off));
+NODE *getstr __P((void));
+int putbyte __P((int v));
+int endinit __P((void));
+int doinit __P((register NODE *p));
+int gotscal __P((void));
+int ilbrace __P((void));
+int irbrace __P((void));
+int upoff __P((int size, register alignment, register *poff));
+int oalloc __P((register struct symtab *p, register *poff));
+int falloc __P((register struct symtab *p, int w, int new, NODE *pty));
+int nidcl __P((NODE *p));
+TWORD types __P((TWORD t1, TWORD t2, TWORD t3));
+NODE *tymerge __P((NODE *typ, NODE *idp));
+int tyreduce __P((register NODE *p));
+int fixtype __P((register NODE *p, int class));
+int uclass __P((register class));
+int fixclass __P((int class, TWORD type));
+struct symtab *mknonuniq __P((int *idindex));
+int lookup __P((char *name, int s));
+int XXXcheckst __P((int lev));
+struct symtab *relook __P((register struct symtab *p));
+int clearst __P((register int lev));
+int hide __P((register struct symtab *p));
+int unhide __P((register struct symtab *p));
+
+/* scan.c */
+int mainp1 __P((int argc, char *argv[]));
+int lxenter __P((register char *s, int m));
+int lxmore __P((register c, register m));
+int lxinit __P((void));
+int lxstr __P((int ct));
+int lxcom __P((void));
+int yylex __P((void));
+int lxres __P((void));
+int lxtitle __P((void));
+char *savestr __P((register char *cp));
+char *hash __P((char *s));
+
+/* stab.c */
+int fixarg __P((struct symtab *p));
+int outstab __P((struct symtab *sym));
+int outstruct __P((int szindex, int paramindex));
+int pstab __P((char *name, int type));
+int pstabdot __P((int type, int value));
+int psline __P((void));
+int plcstab __P((int level));
+int prcstab __P((int level));
+int pfstab __P((char *sname));
+
+/* trees.c */
+int printact __P((NODE *t, int acts));
+NODE *buildtree __P((int o, register NODE *l, register NODE *r));
+int fpe __P((void));
+NODE *fixargs __P((register NODE *p));
+int chkstr __P((int i, int j, TWORD type));
+int conval __P((register NODE *p, int o, register NODE *q));
+int chkpun __P((register NODE *p));
+NODE *stref __P((register NODE *p));
+int notlval __P((register NODE *p));
+NODE *bcon __P((int i));
+NODE *bpsize __P((register NODE *p));
+OFFSZ psize __P((NODE *p));
+NODE *convert __P((register NODE *p, int f));
+int econvert __P((register NODE *p));
+NODE *pconvert __P((register NODE *p));
+NODE *oconvert __P((register NODE *p));
+NODE *ptmatch __P((register NODE *p));
+NODE *tymatch __P((register NODE *p));
+NODE *makety __P((register NODE *p, TWORD t, int d, int s));
+NODE *block __P((int o, register NODE *l, register NODE *r, TWORD t, int d, int s));
+int icons __P((register NODE *p));
+int opact __P((NODE *p));
+int moditype __P((TWORD ty));
+NODE *doszof __P((register NODE *p));
+int eprint __P((register NODE *p, int down, int *a, int *b));
+int prtdcon __P((register NODE *p));
+int ecomp __P((register NODE *p));
+int prtree __P((register NODE *p));
+int p2tree __P((register NODE *p));
+
+/* xdefs.c */
+char *scnames __P((register c));
+
#endif
-/* pass2.h 4.1 85/03/19 */
-
-#ifndef _PASS2_
-#define _PASS2_
+#ifndef _PASS2_H_
+#define _PASS2_H_
-#include "macdefs.h"
+#include <stdio.h>
+/*#include "config.h" manifest.h*/
#include "mac2defs.h"
+/*#include "macdefs.h" manifest.h*/
#include "manifest.h"
-#include "ndu.h"
+/*#include "ndu.h" manifest.h*/
+/*#include "pcclocal.h" mac2defs.h*/
+
+/* pass2.h 4.1 85/03/19 */
+
+/*#ifndef _PASS2_*/
+/*#define _PASS2_*/
+
+/*#include "macdefs.h"*/
+/*#include "mac2defs.h"*/
+/*#include "manifest.h"*/
+/*#include "ndu.h"*/
/* cookies, used as arguments to codgen */
#define FOREFF 01 /* compute for effects only */
*tcopy(),
*getlr();
-extern CONSZ rdin();
-extern int e2print();
+/*extern CONSZ rdin();*/
+/*extern int e2print();*/
extern char *rnames[];
extern int lineno;
extern union mltemplate mltree[];
#endif
+/*#endif*/
+
+#ifndef __P
+#ifdef __STDC__
+#define __P(args) args
+#else
+#define __P(args) ()
+#endif
+#endif
+
+/* allo.c */
+int allo0 __P((void));
+int allo __P((NODE *p, struct optab *q));
+int freetemp __P((int k));
+int freereg __P((NODE *p, int n));
+int usable __P((NODE *p, int n, int r));
+int shareit __P((NODE *p, int r, int n));
+int ushare __P((NODE *p, int f, int r));
+int recl2 __P((register NODE *p));
+int rfree __P((int r, TWORD t));
+int rbusy __P((int r, TWORD t));
+int rwprint __P((int rw));
+int reclaim __P((NODE *p, int rw, int cookie));
+int XXXncopy __P((NODE *q, NODE *p));
+NODE *tcopy __P((register NODE *p));
+int allchk __P((void));
+
+/* fort.c */
+int label __P((int n));
+int tlabel __P((void));
+char *lnread __P((void));
+long lread __P((void));
+int lopen __P((char *s));
+int lcread __P((char *cp, int n));
+int lccopy __P((register n));
+int mainp2 __P((int argc, char *argv[]));
+
+/* local2.c */
+int where2 __P((int c));
+int lineid __P((int l, char *fn));
+int eobl2 __P((void));
+int hopcode __P((int f, int o));
+int tlen __P((NODE *p));
+int mixtypes __P((NODE *p, NODE *q));
+int prtype __P((NODE *n));
+int zzzcode __P((register NODE *p, int c));
+int collapsible __P((NODE *dest, NODE *src));
+int rmove __P((int rt, int rs, TWORD t));
+int setregs __P((void));
+int rewfld __P((NODE *p));
+int callreg __P((NODE *p));
+int base __P((register NODE *p));
+int offset __P((register NODE *p, int tyl));
+int makeor2 __P((register NODE *p, register NODE *q, register int b, register int o));
+int canaddr __P((NODE *p));
+int flshape __P((register NODE *p));
+int shtemp __P((register NODE *p));
+int shumul __P((register NODE *p));
+int adrcon __P((CONSZ val));
+int conput __P((register NODE *p));
+int insput __P((register NODE *p));
+int upput __P((register NODE *p));
+int adrput __P((register NODE *p));
+int acon __P((register NODE *p));
+int genscall __P((register NODE *p, int cookie));
+int gencall __P((register NODE *p, int cookie));
+int cbgen __P((int o, int lab, int mode));
+int nextcook __P((NODE *p, int cookie));
+int lastchance __P((NODE *p, int cook));
+int optim2 __P((register NODE *p));
+NODE *addroreg __P((NODE *l));
+int main __P((int argc, char *argv[]));
+int hardops __P((register NODE *p));
+int zappost __P((NODE *p));
+int fixpre __P((NODE *p));
+int strip __P((register NODE *p));
+int myreader __P((register NODE *p));
+
+/* match.c */
+int tshape __P((NODE *p, int shape));
+int ttype __P((TWORD t, int tword));
+int setrew __P((void));
+int match __P((NODE *p, int cookie));
+int expand __P((NODE *p, int cookie, register char *cp));
+NODE *getlr __P((NODE *p, int c));
+int mlinit __P((void));
+int mlmatch __P((NODE *subtree, int target, int subtarget));
+
+/* order.c */
+int stoasg __P((register NODE *p, int o));
+int deltest __P((register NODE *p));
+int autoincr __P((NODE *p));
+int mkadrs __P((register NODE *p));
+int notoff __P((TWORD t, int r, CONSZ off, char *cp));
+int sucomp __P((register NODE *p));
+int rallo __P((NODE *p, int down));
+int offstar __P((register NODE *p));
+int setincr __P((register NODE *p));
+int setbin __P((register NODE *p));
+int setstr __P((register NODE *p));
+int setasg __P((register NODE *p));
+int setasop __P((register NODE *p));
+int get2lab __P((void));
+int def2lab __P((int l));
+int genargs __P((register NODE *p));
+int argsize __P((register NODE *p));
+
+/* reader.c */
+int p2init __P((int argc, char *argv[]));
+int mainp2 __P((int argc, char *argv[]));
+int p2compile __P((NODE *p));
+int p2bbeg __P((int aoff, int myreg));
+int p2bend __P((void));
+int delay __P((register NODE *p));
+int delay1 __P((register NODE *p));
+int delay2 __P((register NODE *p));
+int codgen __P((NODE *p, int cookie));
+int prcook __P((int cookie));
+int order __P((NODE *p, int cook));
+int store __P((register NODE *p));
+int constore __P((register NODE *p));
+int markcall __P((register NODE *p));
+int stoarg __P((register NODE *p, int calltype));
+int cbranch __P((NODE *p, int true, int false));
+int rcount __P((void));
+int e2print __P((NODE *p, int down, int *a, int *b));
+NODE *eread __P((void));
+CONSZ rdin __P((int base));
+int ffld __P((NODE *p, int down, int *down1, int *down2));
+int oreg2 __P((register NODE *p));
+int canon __P((NODE *p));
+
#endif
+#ifndef _PCCLOCAL_H_
+#define _PCCLOCAL_H_
+
/*#ifndef _H_*/
/*# ifndef TOKENS*/
# define TOKENS 0
# define ENUM 124
# define SM 125
/*# endif LOCALTOKENS*/
+
+#endif
-#ifndef lint
+#include <stdio.h>
+/*#include "config.h" manifest.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass1.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass1.h"
+/*#include "pcclocal.h" macdefs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)pftn.c 1.12 (Berkeley) 4/21/86";
-#endif lint
+#endif
-# include "pass1.h"
+/*# include "pass1.h"*/
unsigned int offsz;
/* defines used for getting things off of the initialization stack */
-
-struct symtab *relook();
-
+/*struct symtab *relook();*/
int ddebug = 0;
-struct symtab * mknonuniq();
+/*struct symtab * mknonuniq();*/
-defid( q, class ) register NODE *q; register int class; {
+int defid(q, class) register NODE *q; register int class; {
register struct symtab *p;
int idp;
register TWORD type;
if( regvar < minrvar ) minrvar = regvar;
break;
}
-
- {
+ {
register int l = p->slevel;
if( l >= MAXSCOPES )
}
-psave( i ){
+int psave(i) int i; {
if( paramno >= PARAMSZ ){
cerror( "parameter stack overflow");
}
paramstk[ paramno++ ] = i;
}
-ftnend(){ /* end of function */
+int ftnend() { /* end of function */
if( retlab != NOLAB ){ /* inside a real function */
efcode();
}
locctr(DATA);
}
-dclargs(){
+int dclargs() {
register i, j;
register struct symtab *p;
register NODE *q;
paramno = 0;
}
-NODE *
-rstruct( idn, soru ){ /* reference to a structure or union, with no definition */
+NODE *rstruct(idn, soru) int idn; int soru; { /* reference to a structure or union, with no definition */
register struct symtab *p;
register NODE *q;
p = &stab[idn];
return( mkty( p->stype, 0, p->sizoff ) );
}
-moedef( idn ){
+int moedef(idn) int idn; {
register NODE *q;
q = block( FREE, NIL, NIL, MOETY, 0, 0 );
if( idn>=0 ) defid( q, MOE );
}
-bstruct( idn, soru ){ /* begining of structure or union declaration */
+int bstruct(idn, soru) int idn; int soru; { /* begining of structure or union declaration */
register NODE *q;
psave( instruct );
return( paramno-4 );
}
-NODE *
-dclstruct( oparam ){
+NODE *dclstruct(oparam) int oparam; {
register struct symtab *p;
register i, al, sa, j, sz, szindex;
register TWORD temp;
*/
-
if( (i=paramstk[oparam+3]) < 0 ){
szindex = curdim;
dstash( 0 ); /* size */
}
/* VARARGS */
-yyerror( s ) char *s; { /* error printing routine in parser */
+int yyerror(s) char *s; { /* error printing routine in parser */
uerror( s );
}
-yyaccpt(){
+int yyaccpt() {
ftnend();
}
-ftnarg( idn ) {
+int ftnarg(idn) int idn; {
switch( stab[idn].stype ){
case UNDEF:
psave( idn );
}
-talign( ty, s) register unsigned ty; register s; {
+int talign(ty, s) register unsigned ty; register s; {
/* compute the alignment of an object with type ty, sizeoff index s */
register i;
}
}
-OFFSZ
-tsize( ty, d, s ) TWORD ty; {
+OFFSZ tsize(ty, d, s) TWORD ty; int d; int s; {
/* compute the size associated with type ty,
dimoff d, and sizoff s */
/* BETTER NOT BE CALLED WHEN t, d, and s REFER TO A BIT FIELD... */
return( (unsigned int) dimtab[ s ] * mult );
}
-inforce( n ) OFFSZ n; { /* force inoff to have the value n */
+int inforce(n) OFFSZ n; { /* force inoff to have the value n */
/* inoff is updated to have the value n */
OFFSZ wb;
register rest;
}
-vfdalign( n ){ /* make inoff have the offset the next alignment of n */
+int vfdalign(n) int n; { /* make inoff have the offset the next alignment of n */
OFFSZ m;
m = inoff;
inforce( m );
}
-
int idebug = 0;
int ibseen = 0; /* the number of } constructions which have been filled */
int ilocctr = 0; /* location counter for current initialization */
-beginit(curid){
+int beginit(curid) int curid; {
/* beginning of initilization; set location ctr and set type */
register struct symtab *p;
}
-instk( id, t, d, s, off ) OFFSZ off; TWORD t; {
+int instk(id, t, d, s, off) int id; TWORD t; int d; int s; OFFSZ off; {
/* make a new entry on the parameter stack to initialize id */
register struct symtab *p;
}
}
-NODE *
-getstr(){ /* decide if the string is external or an initializer, and get the contents accordingly */
+NODE *getstr() { /* decide if the string is external or an initializer, and get the contents accordingly */
register l, temp;
register NODE *p;
}
}
-putbyte( v ){ /* simulate byte v appearing in a list of integer values */
+int putbyte(v) int v; { /* simulate byte v appearing in a list of integer values */
register NODE *p;
p = bcon(v);
incode( p, SZCHAR );
gotscal();
}
-endinit(){
+int endinit() {
register TWORD t;
register d, s, n, d1;
}
-doinit( p ) register NODE *p; {
+int doinit(p) register NODE *p; {
/* take care of generating a value for the initializer p */
/* inoff has the current offset (last bit written)
tfree(p);
}
-gotscal(){
+int gotscal() {
register t, ix;
register n, id;
struct symtab *p;
ifull = 1;
}
-ilbrace(){ /* process an initializer's left brace */
+int ilbrace() { /* process an initializer's left brace */
register t;
struct instk *temp;
pstk = temp;
}
-irbrace(){
+int irbrace() {
/* called when a '}' is seen */
# ifndef BUG1
}
-upoff( size, alignment, poff ) register alignment, *poff; {
+int upoff(size, alignment, poff) int size; register alignment; register *poff; {
/* update the offset pointed to by poff; return the
/* offset of a value of size `size', alignment `alignment',
/* given that off is increasing */
return( off );
}
-oalloc( p, poff ) register struct symtab *p; register *poff; {
+int oalloc(p, poff) register struct symtab *p; register *poff; {
/* allocate p with offset *poff, and update *poff */
register al, off, tsz;
int noff;
off = noff - tsz;
#endif
}
- else
- {
+ else {
off = upoff( tsz, al, &noff );
}
return(0);
}
-falloc( p, w, new, pty ) register struct symtab *p; NODE *pty; {
+int falloc(p, w, new, pty) register struct symtab *p; int w; int new; NODE *pty; {
/* allocate a field of width w */
/* new is 0 if new entry, 1 if redefinition, -1 if alignment */
/* this must be fixed to use the current type in alignments */
switch( new<0?pty->in.type:p->stype ){
- case ENUMTY:
- {
+ case ENUMTY: {
int s;
s = new<0 ? pty->fn.csiz : p->sizoff;
al = dimtab[s+2];
return(0);
}
-nidcl( p ) NODE *p; { /* handle unitialized declarations */
+int nidcl(p) NODE *p; { /* handle unitialized declarations */
/* assumed to be not functions */
register class;
register commflag; /* flag for labelled common declarations */
if( commflag ) commdec( p->tn.rval );
}
-TWORD
-types( t1, t2, t3 ) TWORD t1, t2, t3; {
+TWORD types(t1, t2, t3) TWORD t1; TWORD t2; TWORD t3; {
/* return a basic type from basic types t1, t2, and t3 */
TWORD t[3], noun, adj, unsg;
else return( noun );
}
-NODE *
-tymerge( typ, idp ) NODE *typ, *idp; {
+NODE *tymerge(typ, idp) NODE *typ; NODE *idp; {
/* merge type typ with identifier idp */
register unsigned t;
return( idp );
}
-tyreduce( p ) register NODE *p; {
+int tyreduce(p) register NODE *p; {
/* build a type, and stash away dimensions, from a parse tree of the declaration */
/* the type is build top down, the dimensions bottom up */
}
-fixtype( p, class ) register NODE *p; {
+int fixtype(p, class) register NODE *p; int class; {
register unsigned t, type;
register mod1, mod2;
/* fix up the types, and check for legality */
p->in.type = type;
}
-uclass( class ) register class; {
+int uclass(class) register class; {
/* give undefined version of class */
if( class == SNULL ) return( EXTERN );
else if( class == STATIC ) return( USTATIC );
else return( class );
}
-fixclass( class, type ) TWORD type; {
+int fixclass(class, type) int class; TWORD type; {
/* first, fix null class */
}
}
-struct symtab *
-mknonuniq(idindex) int *idindex; {/* locate a symbol table entry for */
+struct symtab *mknonuniq(idindex) int *idindex; {/* locate a symbol table entry for */
/* an occurrence of a nonunique structure member name */
/* or field */
register i;
return ( sp );
}
-lookup( name, s) char *name; {
+int lookup(name, s) char *name; int s; {
/* look up name: must agree with s w.r.t. STAG, SMOS and SHIDDEN */
register char *p, *q;
#ifndef checkst
/* if not debugging, make checkst a macro */
-XXXcheckst(lev){
+int XXXcheckst(lev) int lev; {
register int s, i, j;
register struct symtab *p, *q;
}
#endif
-struct symtab *
-relook(p) register struct symtab *p; { /* look up p again, and see where it lies */
+struct symtab *relook(p) register struct symtab *p; { /* look up p again, and see where it lies */
register struct symtab *q;
return(q);
}
-clearst( lev ) register int lev; {
+int clearst(lev) register int lev; {
register struct symtab *p, *q;
register int temp;
struct symtab *clist = 0;
aoend();
}
-hide( p ) register struct symtab *p; {
+int hide(p) register struct symtab *p; {
register struct symtab *q;
for( q=p+1; ; ++q ){
if( q >= &stab[SYMTSZ] ) q = stab;
return( idname = q-stab );
}
-unhide( p ) register struct symtab *p; {
+int unhide(p) register struct symtab *p; {
register struct symtab *q;
register s, j;
-#ifndef lint
+/*#include <stdio.h> pass2.h*/
+/*#include "config.h" manifest.h*/
+/*#include "mac2defs.h" pass2.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass2.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass2.h"
+/*#include "pcclocal.h" mac2defs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)reader.c 4.4 (Berkeley) 8/22/85";
-#endif lint
+#endif
-# include "pass2.h"
+/*# include "pass2.h"*/
/* some storage declarations */
OFFSZ baseoff = 0;
OFFSZ maxtemp = 0;
-p2init( argc, argv ) char *argv[];{
+int p2init(argc, argv) int argc; char *argv[]; {
/* set the values of the pass 2 arguments */
register int c;
}
# if !defined(FORT) && !defined(ONEPASS)
-unsigned int caloff();
+/*unsigned int caloff();*/
unsigned int offsz;
-mainp2( argc, argv ) char *argv[]; {
+int mainp2(argc, argv) int argc; char *argv[]; {
register files;
register temp;
register c;
# endif
# ifdef ONEPASS
-p2compile( p ) NODE *p; {
+int p2compile(p) NODE *p; {
if( lflag ) lineid( lineno, ftitle );
tmpoff = baseoff; /* expression at top level reuses temps */
/* first pass will do it... */
}
-p2bbeg( aoff, myreg ) {
+int p2bbeg(aoff, myreg) int aoff; int myreg; {
static int myftn = -1;
tmpoff = baseoff = (unsigned int) aoff;
setregs();
}
-p2bend(){
+int p2bend() {
SETOFF( maxoff, ALSTACK );
eobl2();
}
NODE *deltrees[DELAYS];
int deli;
-delay( p ) register NODE *p; {
+int delay(p) register NODE *p; {
/* look in all legal places for COMOP's and ++ and -- ops to delay */
/* note; don't delay ++ and -- within calls or things like
/* getchar (in their macro forms) will start behaving strangely */
for( i = 0; i<deli; ++i ) codgen( deltrees[i], FOREFF ); /* do the rest */
}
-delay1( p ) register NODE *p; { /* look for COMOPS */
+int delay1(p) register NODE *p; { /* look for COMOPS */
register o, ty;
o = p->in.op;
return( delay1(p->in.left) || delay1(p->in.right ) );
}
-delay2( p ) register NODE *p; {
+int delay2(p) register NODE *p; {
/* look for delayable ++ and -- operators */
if( ty != LTYPE ) delay2( p->in.left );
}
-codgen( p, cookie ) NODE *p; {
+int codgen(p, cookie) NODE *p; int cookie; {
/* generate the code for p;
order may call codgen recursively */
0,
};
-prcook( cookie ){
+int prcook(cookie) int cookie; {
/* print a nice-looking description of cookie */
int odebug = 0;
-order(p,cook) NODE *p; {
+int order(p, cook) NODE *p; int cook; {
register o, ty, m;
int m1;
if( setasg( p ) ) goto again;
goto nomat;
-
case BITYPE:
if( setbin( p ) ) goto again;
/* try to replace binary ops by =ops */
int callflag;
int fregs;
-store( p ) register NODE *p; {
+int store(p) register NODE *p; {
/* find a subtree of p which should be stored */
store( p->in.left );
}
-constore( p ) register NODE *p; {
+int constore(p) register NODE *p; {
/* store conditional expressions */
/* the point is, avoid storing expressions in conditional
store( p );
}
-markcall( p ) register NODE *p; { /* mark off calls below the current node */
+int markcall(p) register NODE *p; { /* mark off calls below the current node */
again:
switch( p->in.op ){
}
-stoarg( p, calltype ) register NODE *p; {
+int stoarg(p, calltype) register NODE *p; int calltype; {
/* arrange to store the args */
if( p->in.op == CM ){
int negrel[] = { NE, EQ, GT, GE, LT, LE, UGT, UGE, ULT, ULE } ; /* negatives of relationals */
-cbranch( p, true, false ) NODE *p; {
+int cbranch(p, true, false) NODE *p; int true; int false; {
/* evaluate p for truth value, and branch to true or false
/* accordingly: label <0 means fall through */
}
-rcount(){ /* count recursions */
+int rcount() { /* count recursions */
if( ++nrecur > NRECUR ){
cerror( "expression causes compiler loop: try simplifying" );
}
}
# ifndef BUG4
-e2print( p, down, a, b ) NODE *p; int *a, *b; {
+int e2print(p, down, a, b) NODE *p; int down; int *a; int *b; {
*a = *b = down+1;
while( down >= 2 ){
}
if( down-- ) printf( " " );
-
printf( "%o) %s", p, opst[p->in.op] );
switch( p->in.op ) { /* special cases */
# endif
# if !defined(FORT) && !defined(ONEPASS)
-NODE *
-eread(){
+NODE *eread() {
/* call eread recursively to get subtrees, if any */
}
-CONSZ
-rdin( base ){
+CONSZ rdin(base) int base; {
register sign, c;
CONSZ val;
#ifndef FIELDOPS
/* do this if there is no special hardware support for fields */
-ffld( p, down, down1, down2 ) NODE *p; int *down1, *down2; {
+int ffld(p, down, down1, down2) NODE *p; int down; int *down1; int *down2; {
/* look for fields that are not in an lvalue context, and rewrite them... */
register NODE *shp;
register s, o, v, ty;
}
#endif
-oreg2( p ) register NODE *p; {
+int oreg2(p) register NODE *p; {
/* look for situations where2 we can turn * into OREG */
}
}
-
#endif
if( (q->in.op==PLUS || q->in.op==MINUS) && qr->in.op == ICON &&
}
-canon(p) NODE *p; {
+int canon(p) NODE *p; {
/* put p in canonical form */
int oreg2(), sucomp();
walkf( p, sucomp ); /* do the Sethi-Ullman computation */
}
-
-#ifndef lint
+/*#include <ctype.h> gen.h*/
+#include <gen.h>
+#include <stab.h>
+#include <stdio.h>
+/*#include <strings.h> gen.h*/
+/*#include <sys/signal.h> gen.h*/
+/*#include "config.h" manifest.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass1.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass1.h"
+/*#include "pcclocal.h" macdefs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)scan.c 2.1 (Berkeley) 4/23/86";
-#endif lint
+#endif
-# include "pass1.h"
-# include <a.out.h>
-# include <stab.h>
-# include <ctype.h>
-# include <signal.h>
+/*# include "pass1.h"*/
+/*# include <a.out.h>*/
+/*# include <stab.h>*/
+/*# include <ctype.h>*/
+/*# include <signal.h>*/
/* temporarily */
extern int proflg;
extern int gdebug;
-extern int fpe();
+/*extern int fpe();*/
struct sigvec fpe_sigvec;
int oldway; /* allocate storage so lint will compile as well */
#ifndef LINT
extern int lastloc;
#endif
-unsigned caloff();
+/*unsigned caloff();*/
/* ARGSUSED */
-mainp1( argc, argv ) int argc; char *argv[]; { /* control multiple files */
+int mainp1(argc, argv) int argc; char *argv[]; { /* control multiple files */
register i;
register char *cp;
short lxmask[CSSZ+1];
-lxenter( s, m ) register char *s; register short m; {
+int lxenter(s, m) register char *s; int m; {
/* enter a mask into lxmask */
register c;
}
-
# define lxget(c,m) (lxgcp=yytext,lxmore(c,m))
-lxmore( c, m ) register c, m; {
+int lxmore(c, m) register c; register m; {
register char *cp;
*(cp = lxgcp) = c;
struct lxdope *lxcp[CSSZ+1];
-lxinit(){
+int lxinit() {
register struct lxdope *p;
register i;
register char *cp;
int lxmatch; /* character to be matched in char or string constant */
-lxstr(ct){
+int lxstr(ct) int ct; {
/* match a string or character constant, up to lxmatch */
register c;
}
}
-lxcom(){
+int lxcom() {
register c;
/* saw a /*: process a comment */
# ifdef LINT
case 'V':
- lxget( c, LEXLET|LEXDIG );
- {
+ lxget( c, LEXLET|LEXDIG ); {
extern int vaflag;
int i;
i = yytext[7]?yytext[7]-'0':0;
}
case 'L':
lxget( c, LEXLET );
- if( strcmp( yytext, "LINTLIBRARY" ) ) continue;
- {
+ if( strcmp( yytext, "LINTLIBRARY" ) ) continue; {
extern int libflag;
libflag = 1;
}
case 'A':
lxget( c, LEXLET );
- if( strcmp( yytext, "ARGSUSED" ) ) continue;
- {
+ if( strcmp( yytext, "ARGSUSED" ) ) continue; {
extern int argflag, vflag;
argflag = 1;
vflag = 0;
}
}
-yylex(){
+int yylex() {
for(;;){
register lxchar;
case 'X':
if( yytext[0] != '0' && !yytext[1] ) uerror( "illegal hex constant" );
lxmore( lxchar, LEXHEX );
- /* convert the value */
- {
+ /* convert the value */ {
register char *cp;
for( cp = yytext+2; *cp; ++cp ){
/* this code won't work for all wild character sets,
yylval.intval = 0;
return( ICON );
- case A_BCD:
- {
+ case A_BCD: {
register i;
int j;
for( i=0; i<LXTSZ; ++i ){
"", 0, 0, /* to stop the search */
};
-lxres() {
+int lxres() {
/* check to see of yytext is reserved; if so,
/* do the appropriate action and return */
/* otherwise, return -1 */
extern int labelno;
-lxtitle(){
+int lxtitle() {
/* called after a newline; set linenumber and file name */
register c, val;
char *savetab;
int saveleft;
-char *
-savestr(cp)
- register char *cp;
-{
+char *savestr(cp) register char *cp; {
register int len;
len = strlen(cp) + 1;
int ht_used;
} htab[MAXHASH];
-char *
-hash(s)
- char *s;
-{
+char *hash(s) char *s; {
register char **h;
register i;
register char *cp;
-#ifndef lint
+#include <gen.h>
+#include <stab.h>
+#include <stdio.h>
+/*#include "config.h" manifest.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass1.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass1.h"
+/*#include "pcclocal.h" macdefs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)stab.c 1.12 (Berkeley) 3/27/86";
#endif
/*
* symbolic debugging information into the object file.
*/
-#include "pass1.h"
+/*#include "pass1.h"*/
-#include <sys/types.h>
-#include <a.out.h>
-#include <stab.h>
+/*#include <sys/types.h>*/
+/*#include <a.out.h>*/
+/*#include <stab.h>*/
#define bytes(bits) ((bits) / SZCHAR)
#define bsize(p) bytes(dimtab[p->sizoff]) /* size in bytes of a symbol */
extern int ddebug;
extern int gdebug;
-extern char *malloc();
+/*extern char *malloc();*/
int stabLCSYM;
* since the types are read later.
*/
-fixarg(p)
-struct symtab *p;
-{
+static bool zero_length_array __P((register struct symtab *p));
+static Typeid typelookup __P((TWORD type, int arrindex, int strindex, int strtag));
+static int entertype __P((TWORD type, int arrindex, int strindex, int strtag));
+static reentertype __P((Typeid typeid, TWORD type, int arrindex, int strindex, int strtag));
+static inittypes __P((void));
+static maketype __P((char *name, int tnum, int eqtnum, long lower, long upper));
+static gentype __P((struct symtab *sym));
+static genstruct __P((TWORD t, int structid, int index, char *name, int size));
+static geninfo __P((register struct symtab *p));
+static old_fixarg __P((struct symtab *p));
+static old_outstab __P((struct symtab *p));
+static old_pstab __P((char *name, int type));
+static old_pstabdot __P((int type, int value));
+static old_poffs __P((register struct symtab *p));
+static old_psline __P((void));
+static old_plcstab __P((int level));
+static old_prcstab __P((int level));
+static old_pfstab __P((char *sname));
+
+int fixarg(p) struct symtab *p; {
if (oldway) {
old_fixarg(p);
} else if (gdebug) {
* such entries.
*/
-static bool zero_length_array(p)
-register struct symtab *p;
-{
+static bool zero_length_array(p) register struct symtab *p; {
bool b;
int t;
* Generate debugging info for a given symbol.
*/
-outstab(sym)
-struct symtab *sym;
-{
+int outstab(sym) struct symtab *sym; {
register struct symtab *p;
char *classname;
int offset;
* Look for the given type word in the type table.
*/
-static Typeid typelookup(type, arrindex, strindex, strtag)
-TWORD type;
-int arrindex;
-int strindex;
-int strtag;
-{
+static Typeid typelookup(type, arrindex, strindex, strtag) TWORD type; int arrindex; int strindex; int strtag; {
register TWORD tword;
register int i1, i2;
Typeid t;
* Enter a type word && associated symtab indices into the type table.
*/
-static int entertype(type, arrindex, strindex, strtag)
-TWORD type;
-int arrindex;
-int strindex;
-int strtag;
-{
+static int entertype(type, arrindex, strindex, strtag) TWORD type; int arrindex; int strindex; int strtag; {
register Typeid t;
register int i;
* as the old one.
*/
-static reentertype(typeid, type, arrindex, strindex, strtag)
-Typeid typeid;
-TWORD type;
-int arrindex;
-int strindex;
-int strtag;
-{
+static reentertype(typeid, type, arrindex, strindex, strtag) Typeid typeid; TWORD type; int arrindex; int strindex; int strtag; {
register Typeid t;
register int i;
#define builtintype(type) entertype(type, NILINDEX, NILINDEX, NILINDEX)
-static inittypes()
-{
+static inittypes() {
int t;
t_int = builtintype(INT);
* Generate info for a new range type.
*/
-static maketype(name, tnum, eqtnum, lower, upper)
-char *name;
-int tnum, eqtnum;
-long lower, upper;
-{
+static maketype(name, tnum, eqtnum, lower, upper) char *name; int tnum; int eqtnum; long lower; long upper; {
printf("\t.stabs\t\"%s:t%d=r%d;%d;%d;", name, tnum, eqtnum, lower, upper);
geninfo(0);
}
* Generate debugging information for the given type of the given symbol.
*/
-static gentype(sym)
-struct symtab *sym;
-{
+static gentype(sym) struct symtab *sym; {
register struct symtab *p;
register TWORD t;
register TWORD basictype;
* Generate type information for structures, unions, && enumerations.
*/
-static genstruct(t, structid, index, name, size)
-TWORD t;
-int structid;
-int index;
-char *name;
-int size;
-{
+static genstruct(t, structid, index, name, size) TWORD t; int structid; int index; char *name; int size; {
register int i;
register struct symtab *field;
int id;
* Generate offset && size info.
*/
-static geninfo(p)
-register struct symtab *p;
-{
+static geninfo(p) register struct symtab *p; {
int stabtype;
if (p == 0) {
* Generate information for a newly-defined structure.
*/
-outstruct(szindex, paramindex)
-int szindex, paramindex;
-{
+int outstruct(szindex, paramindex) int szindex; int paramindex; {
register Typeid typeid;
register struct symtab *p;
register int i, t, strindex;
}
}
-pstab(name, type)
-char *name;
-int type;
-{
+int pstab(name, type) char *name; int type; {
register int i;
register char c;
}
#ifdef STABDOT
-pstabdot(type, value)
-int type;
-int value;
-{
+int pstabdot(type, value) int type; int value; {
if ( ! gdebug) {
return;
} else if (oldway) {
extern int labelno;
extern int fdefflag;
-psline()
-{
+int psline() {
static int lastlineno;
register char *cp, *cq;
register int i;
}
}
-plcstab(level)
-int level;
-{
+int plcstab(level) int level; {
if (!gdebug) {
return;
} else if (oldway) {
#endif
}
-prcstab(level)
-int level;
-{
+int prcstab(level) int level; {
if (!gdebug) {
return;
} else if (oldway) {
#endif
}
-pfstab(sname)
-char *sname;
-{
+int pfstab(sname) char *sname; {
register struct symtab *p;
if (gdebug) {
* Old way of doing things.
*/
-static old_fixarg(p)
-struct symtab *p; {
+static old_fixarg(p) struct symtab *p; {
if (gdebug) {
old_pstab(p->sname, N_PSYM);
if (gdebug) printf("0,%d,%d\n", p->stype, argoff/SZCHAR);
}
}
-static old_outstab(p)
-struct symtab *p; {
+static old_outstab(p) struct symtab *p; {
register TWORD ptype;
register char *pname;
register char pclass;
}
}
-static old_pstab(name, type)
-char *name;
-int type; {
+static old_pstab(name, type) char *name; int type; {
register int i;
register char c;
if (!gdebug) return;
}
#ifdef STABDOT
-static old_pstabdot(type, value)
- int type;
- int value;
-{
+static old_pstabdot(type, value) int type; int value; {
if ( ! gdebug) return;
/* locctr(PROG); /* .stabs must appear in .text for c2 */
printf("\t.stabd\t");
}
#endif
-static old_poffs(p)
-register struct symtab *p; {
+static old_poffs(p) register struct symtab *p; {
int s;
if (!gdebug) return;
if ((s = dimtab[p->sizoff]/SZCHAR) > 1) {
}
}
-static old_plcstab(level) {
+static old_plcstab(level) int level; {
if (!gdebug) return;
#ifdef STABDOT
old_pstabdot(N_LBRAC, level);
#endif
}
-static old_prcstab(level) {
+static old_prcstab(level) int level; {
if (!gdebug) return;
#ifdef STABDOT
pstabdot(N_RBRAC, level);
#endif
}
-static old_pfstab(sname)
-char *sname; {
+static old_pfstab(sname) char *sname; {
if (!gdebug) return;
pstab(sname, N_FUN);
#ifndef FLEXNAMES
-#ifndef lint
+/*#include "manifest.h" pass2.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass2.h"
+/*#include "pcclocal.h" manifest.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)table.c 1.13 (Berkeley) 1/8/86";
-#endif lint
+#endif
-# include "pass2.h"
+/*# include "pass2.h"*/
# define WPTR TPTRTO|TINT|TLONG|TFLOAT|TDOUBLE|TPOINT|TUNSIGNED|TULONG
# define AWD SNAME|SOREG|SCON|STARNM|STARREG
NAREG|NASL, RESC1|RESCC,
" ZA\n",
-
INIT, FOREFF,
SCON, TANY,
SANY, TWORD,
OPUNARY, DF(UNARY MINUS),
-
ASG OPANY, DF(ASG PLUS),
OPANY, DF(BITYPE),
-#ifndef lint
+#include <setjmp.h>
+#include <stdio.h>
+/*#include "config.h" manifest.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass1.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass1.h"
+/*#include "pcclocal.h" macdefs.h*/
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)trees.c 4.10 (Berkeley) 1/8/86";
#endif
-# include "pass1.h"
+/*# include "pass1.h"*/
-# include <setjmp.h>
+/*# include <setjmp.h>*/
int bdebug = 0;
int adebug = 0;
extern ddebug;
-extern eprint();
+/*extern eprint();*/
/* corrections when in violation of lint */
# define NCVTR 010000
#ifndef BUG1
-printact(t, acts)
- NODE *t;
- int acts;
-{
+int printact(t, acts) NODE *t; int acts; {
static struct actions {
int a_bit;
char *a_name;
*/
-NODE *
-buildtree( o, l, r ) register NODE *l, *r; {
+NODE *buildtree(o, l, r) int o; register NODE *l; register NODE *r; {
register NODE *p, *q;
register actions;
register opty;
* local code must unwind it
* back to PLUS/MINUS REG ICON
* according to local conventions
- */
- {
+ */ {
extern NODE * addroreg();
p->in.op = FREE;
p = addroreg( l );
/* take the addresses of the two sides; then make an
/* operator using STASG and
/* the addresses of left and right */
-
- {
+ {
register TWORD t;
register d, s;
int fpe_count = -1;
jmp_buf gotfpe;
-fpe() {
+int fpe() {
if (fpe_count < 0)
cerror("floating point exception");
++fpe_count;
* precision floating point constants are
* cast to double (to eliminate convert code).
*/
-NODE *
-fixargs( p ) register NODE *p; {
+NODE *fixargs(p) register NODE *p; {
int o = p->in.op;
if( o == CM ){
return( p );
}
-chkstr( i, j, type ) TWORD type; {
+int chkstr(i, j, type) int i; int j; TWORD type; {
/* is the MOS or MOU at stab[i] OK for strict reference by a ptr */
/* i has been checked to contain a MOS or MOU */
/* j is the index in dimtab of the members... */
return( 0 );
}
-conval( p, o, q ) register NODE *p, *q; {
+int conval(p, o, q) register NODE *p; int o; register NODE *q; {
/* apply the op o to the lval part of p; if binary, rhs is val */
int i, u;
CONSZ val;
return(1);
}
-chkpun(p) register NODE *p; {
+int chkpun(p) register NODE *p; {
/* checks p for the existance of a pun */
}
-NODE *
-stref( p ) register NODE *p; {
+NODE *stref(p) register NODE *p; {
TWORD t;
int d, s, dsc, align;
return( clocal(p) );
}
-notlval(p) register NODE *p; {
+int notlval(p) register NODE *p; {
/* return 0 if p an lvalue, 1 otherwise */
}
-NODE *
-bcon( i ){ /* make a constant node with value i */
+NODE *bcon(i) int i; { /* make a constant node with value i */
register NODE *p;
p = block( ICON, NIL, NIL, INT, 0, INT );
return( clocal(p) );
}
-NODE *
-bpsize(p) register NODE *p; {
+NODE *bpsize(p) register NODE *p; {
return( offcon( psize(p), p->in.type, p->fn.cdim, p->fn.csiz ) );
}
-OFFSZ
-psize( p ) NODE *p; {
+OFFSZ psize(p) NODE *p; {
/* p is a node of type pointer; psize returns the
size of the thing pointed to */
return( tsize( DECREF(p->in.type), p->fn.cdim, p->fn.csiz ) );
}
-NODE *
-convert( p, f ) register NODE *p; {
+NODE *convert(p, f) register NODE *p; int f; {
/* convert an operand of p
f is either CVTL or CVTR
operand has type int, and is converted by the size of the other side
}
#ifndef econvert
-econvert( p ) register NODE *p; {
+int econvert(p) register NODE *p; {
/* change enums to ints, or appropriate types */
}
#endif
-NODE *
-pconvert( p ) register NODE *p; {
+NODE *pconvert(p) register NODE *p; {
/* if p should be changed into a pointer, do so */
return( p );
}
-NODE *
-oconvert(p) register NODE *p; {
+NODE *oconvert(p) register NODE *p; {
/* convert the result itself: used for pointer and unsigned */
switch(p->in.op) {
return(p);
}
-NODE *
-ptmatch(p) register NODE *p; {
+NODE *ptmatch(p) register NODE *p; {
/* makes the operands of p agree; they are
either pointers or integers, by this time */
int tdebug = 0;
-NODE *
-tymatch(p) register NODE *p; {
+NODE *tymatch(p) register NODE *p; {
/* satisfy the types of various arithmetic binary ops */
return(p);
}
-NODE *
-makety( p, t, d, s ) register NODE *p; TWORD t; {
+NODE *makety(p, t, d, s) register NODE *p; TWORD t; int d; int s; {
/* make p into type t by inserting a conversion */
if( p->in.type == ENUMTY && p->in.op == ICON ) econvert(p);
}
-NODE *
-block( o, l, r, t, d, s ) register NODE *l, *r; TWORD t; {
+NODE *block(o, l, r, t, d, s) int o; register NODE *l; register NODE *r; TWORD t; int d; int s; {
register NODE *p;
return(p);
}
-icons(p) register NODE *p; {
+int icons(p) register NODE *p; {
/* if p is an integer constant, return its value */
int val;
# define MENU 040 /* enumeration variable or member */
# define MVOID 0100000 /* void type */
-opact( p ) NODE *p; {
+int opact(p) NODE *p; {
register mt12, mt1, mt2, o;
return( NCVT );
}
-moditype( ty ) TWORD ty; {
+int moditype(ty) TWORD ty; {
switch( ty ){
}
}
-NODE *
-doszof( p ) register NODE *p; {
+NODE *doszof(p) register NODE *p; {
/* do sizeof p */
int i;
}
# ifndef BUG2
-eprint( p, down, a, b ) register NODE *p; int *a, *b; {
+int eprint(p, down, a, b) register NODE *p; int down; int *a; int *b; {
register ty;
*a = *b = down+1;
}
# endif
-prtdcon( p ) register NODE *p; {
+int prtdcon(p) register NODE *p; {
int o = p->in.op, i;
if( o == DCON || o == FCON ){
}
}
-
int edebug = 0;
-ecomp( p ) register NODE *p; {
+int ecomp(p) register NODE *p; {
# ifndef BUG2
if( edebug ) fwalk( p, eprint, 0 );
# endif
# ifdef STDPRTREE
# ifndef ONEPASS
-prtree(p) register NODE *p; {
+int prtree(p) register NODE *p; {
register struct symtab *q;
register ty;
# else
-p2tree(p) register NODE *p; {
+int p2tree(p) register NODE *p; {
register ty;
# ifdef MYP2TREE
-#ifndef lint
+#include <stdio.h>
+/*#include "config.h" manifest.h*/
+/*#include "macdefs.h" manifest.h*/
+/*#include "manifest.h" pass1.h*/
+/*#include "ndu.h" manifest.h*/
+#include "pass1.h"
+
+#if defined(DOSCCS) && !defined(lint)
static char *sccsid ="@(#)xdefs.c 4.3 (Berkeley) 3/19/85";
-#endif lint
+#endif
-# include "pass1.h"
+/*# include "pass1.h"*/
/* communication between lexical routines */
float fcon; /* the last float read by the lexical analyzer */
double dcon; /* the last double read by the lexical analyzer */
-
/* symbol table maintainence */
struct symtab stab[SYMTSZ+1]; /* one extra slot for scratch */
int idname; /* tunnel to buildtree for name id's */
-
NODE node[TREESZ];
int cflag = 0; /* do we check for funny casts */
"USTATIC",
};
-char * scnames( c ) register c; {
+char *scnames(c) register c; {
/* return the name for storage class c */
static char buf[12];
if( c&FIELD ){