xref: /csrg-svn/old/pcc/mip/pass1.h (revision 24405)
1*24405Smckusick /*	pass1.h	4.2	85/08/22	*/
218383Sralph 
318383Sralph #ifndef _PASS1_
418383Sralph #define	_PASS1_
518383Sralph 
618383Sralph #include "macdefs.h"
718383Sralph #include "manifest.h"
818383Sralph 
918383Sralph /*
1018383Sralph  * Symbol table definition.
11*24405Smckusick  *
12*24405Smckusick  * Colliding entries are moved down with a standard
13*24405Smckusick  * probe (no quadratic rehash here) and moved back when
14*24405Smckusick  * entries are cleared.
1518383Sralph  */
1618383Sralph struct	symtab {
1718383Sralph #ifndef FLEXNAMES
1818383Sralph 	char	sname[NCHNAM];
1918383Sralph #else
2018383Sralph 	char	*sname;
2118383Sralph #endif
22*24405Smckusick 	struct	symtab *snext;	/* link to other symbols in the same scope */
2318383Sralph 	TWORD	stype;		/* type word */
2418383Sralph 	char	sclass;		/* storage class */
2518383Sralph 	char	slevel;		/* scope level */
2618383Sralph 	char	sflags;		/* flags, see below */
2718383Sralph 	int	offset;		/* offset or value */
2818383Sralph 	short	dimoff;		/* offset into the dimension table */
2918383Sralph 	short	sizoff;		/* offset into the size table */
30*24405Smckusick 	int	suse;		/* line number of last use of the variable */
3118383Sralph };
3218383Sralph 
3318383Sralph /*
3418383Sralph  * Storage classes
3518383Sralph  */
3618383Sralph #define SNULL		0		/* initial value */
3718383Sralph #define AUTO		1		/* automatic (on stack) */
3818383Sralph #define EXTERN		2		/* external reference */
3918383Sralph #define STATIC		3		/* static scope */
4018383Sralph #define REGISTER	4		/* register requested */
4118383Sralph #define EXTDEF		5		/* external definition */
4218383Sralph #define LABEL		6		/* label definition */
4318383Sralph #define ULABEL		7		/* undefined label reference */
4418383Sralph #define MOS		8		/* member of structure */
4518383Sralph #define PARAM		9		/* parameter */
4618383Sralph #define STNAME		10		/* structure name */
4718383Sralph #define MOU		11		/* member of union */
4818383Sralph #define UNAME		12		/* union name */
4918383Sralph #define TYPEDEF		13		/* typedef name */
5018383Sralph #define FORTRAN		14		/* fortran function */
5118383Sralph #define ENAME		15		/* enumeration name */
5218383Sralph #define MOE		16		/* member of enumeration */
5318383Sralph #define UFORTRAN 	17		/* undefined fortran reference */
5418383Sralph #define USTATIC		18		/* undefined static reference */
5518383Sralph 
5618383Sralph /* field size is ORed in */
5718383Sralph #define FIELD		0100
5818383Sralph #define FLDSIZ		077
5918383Sralph #ifndef BUG1
6018383Sralph extern	char *scnames();
6118383Sralph #endif
6218383Sralph 
6318383Sralph /*
6418383Sralph  * Symbol table flags
6518383Sralph  */
6618383Sralph #define SMOS		01		/* member of structure */
6718383Sralph #define SHIDDEN		02		/* hidden in current scope */
6818383Sralph #define SHIDES		04		/* hides symbol in outer scope */
6918383Sralph #define SSET		010		/* symbol assigned to */
7018383Sralph #define SREF		020		/* symbol referenced */
7118383Sralph #define SNONUNIQ	040		/* non-unique structure member */
7218383Sralph #define STAG		0100		/* structure tag name */
7318383Sralph 
7418383Sralph /*
7518383Sralph  * Location counters
7618383Sralph  */
7718383Sralph #define PROG		0		/* program segment */
7818383Sralph #define DATA		1		/* data segment */
7918383Sralph #define ADATA		2		/* array data segment */
8018383Sralph #define STRNG		3		/* string data segment */
8118383Sralph #define ISTRNG		4		/* initialized string segment */
8218383Sralph #define STAB		5		/* symbol table segment */
8318383Sralph 
8418383Sralph 
8518383Sralph #ifndef ONEPASS
8618383Sralph #include "ndu.h"
8718383Sralph #endif
8818383Sralph 
8918383Sralph 
9018383Sralph #ifndef FIXDEF
9118383Sralph #define FIXDEF(p)
9218383Sralph #endif
9318383Sralph #ifndef FIXARG
9418383Sralph #define FIXARG(p)
9518383Sralph #endif
9618383Sralph #ifndef FIXSTRUCT
9718383Sralph #define FIXSTRUCT(a,b)
9818383Sralph #endif
9918383Sralph 
10018383Sralph 	/* alignment of initialized quantities */
10118383Sralph #ifndef AL_INIT
10218383Sralph #define	AL_INIT ALINT
10318383Sralph #endif
10418383Sralph 
10518383Sralph /*
10618383Sralph  * External definitions
10718383Sralph  */
10818383Sralph struct sw {		/* switch table */
10918383Sralph 	CONSZ	sval;	/* case value */
11018383Sralph 	int	slab;	/* associated label */
11118383Sralph };
11218383Sralph extern	struct sw swtab[];
11318383Sralph extern	struct sw *swp;
11418383Sralph extern	int swx;
11518383Sralph 
11618383Sralph extern	int ftnno;
11718383Sralph extern	int blevel;
11818383Sralph extern	int instruct, stwart;
11918383Sralph 
12018383Sralph extern	int lineno, nerrors;
12118383Sralph 
12218383Sralph extern	CONSZ lastcon;
12318383Sralph extern	float fcon;
12418383Sralph extern	double dcon;
12518383Sralph 
12618383Sralph extern	char ftitle[];
12718383Sralph extern	char ititle[];
12818383Sralph extern	struct symtab stab[];
12918383Sralph extern	int curftn;
13018383Sralph extern	int curclass;
13118383Sralph extern	int curdim;
13218383Sralph extern	int dimtab[];
13318383Sralph extern	int paramstk[];
13418383Sralph extern	int paramno;
13518383Sralph extern	int autooff, argoff, strucoff;
13618383Sralph extern	int regvar;
13718383Sralph extern	int minrvar;
13818383Sralph extern	int brkflag;
13918383Sralph typedef union {
14018383Sralph 	int intval;
14118383Sralph 	NODE * nodep;
14218383Sralph 	} YYSTYPE;
14318383Sralph extern	YYSTYPE yylval;
14418383Sralph extern	char yytext[];
14518383Sralph 
14618383Sralph extern	int strflg;
14718383Sralph 
14818383Sralph extern	OFFSZ inoff;
14918383Sralph 
15018383Sralph extern	int reached;
15118383Sralph 
15218383Sralph /* tunnel to buildtree for name id's */
15318383Sralph extern	int idname;
15418383Sralph 
15518383Sralph extern	NODE node[];
15618383Sralph extern	NODE *lastfree;
15718383Sralph 
15818383Sralph extern	int cflag, hflag, pflag;
15918383Sralph 
16018383Sralph /* various labels */
16118383Sralph extern	int brklab;
16218383Sralph extern	int contlab;
16318383Sralph extern	int flostat;
16418383Sralph extern	int retlab;
16518383Sralph extern	int retstat;
16618383Sralph extern	int asavbc[], *psavbc;
16718383Sralph 
16818383Sralph /* declarations of various functions */
16918383Sralph extern	NODE
17018383Sralph 	*buildtree(),
17118383Sralph 	*bdty(),
17218383Sralph 	*mkty(),
17318383Sralph 	*rstruct(),
17418383Sralph 	*dclstruct(),
17518383Sralph 	*getstr(),
17618383Sralph 	*tymerge(),
17718383Sralph 	*stref(),
17818383Sralph 	*offcon(),
17918383Sralph 	*bcon(),
18018383Sralph 	*bpsize(),
18118383Sralph 	*convert(),
18218383Sralph 	*pconvert(),
18318383Sralph 	*oconvert(),
18418383Sralph 	*ptmatch(),
18518383Sralph 	*tymatch(),
18618383Sralph 	*makety(),
18718383Sralph 	*block(),
18818383Sralph 	*doszof(),
18918383Sralph 	*talloc(),
19018383Sralph 	*optim(),
19118383Sralph 	*fixargs(),
19218383Sralph 	*clocal();
19318383Sralph OFFSZ	tsize(),
19418383Sralph 	psize();
19518383Sralph TWORD	types();
19618383Sralph double	atof();
19718383Sralph char	*exname(), *exdcon();
19818383Sralph 
19918383Sralph #define checkst(x)
20018383Sralph 
20118383Sralph #ifndef CHARCAST
20218383Sralph /* to make character constants into character connstants */
20318383Sralph /* this is a macro to defend against cross-compilers, etc. */
20418383Sralph #define CHARCAST(x) (char)(x)
20518383Sralph #endif
20618383Sralph #endif
20718383Sralph 
20818383Sralph /*
20918383Sralph  * Flags used in structures/unions
21018383Sralph  */
21118383Sralph #define SEENAME		01
21218383Sralph #define INSTRUCT	02
21318383Sralph #define INUNION		04
21418383Sralph #define FUNNYNAME	010
21518383Sralph #define TAGNAME		020
21618383Sralph 
21718383Sralph /*
21818383Sralph  * Flags used in the (elementary) flow analysis ...
21918383Sralph  */
22018383Sralph #define FBRK		02
22118383Sralph #define FCONT		04
22218383Sralph #define FDEF		010
22318383Sralph #define FLOOP		020
22418383Sralph 
22518383Sralph /*
22618383Sralph  * Flags used for return status
22718383Sralph  */
22818383Sralph #define RETVAL		1
22918383Sralph #define NRETVAL		2
23018383Sralph 
23118383Sralph #define NONAME		040000		/* marks constant w/o name field */
23218383Sralph #define NOOFFSET	(-10201)	/* mark an offset which is undefined */
23318383Sralph 
234