xref: /original-bsd/old/pcc/mip/pass1.h (revision 2f906f46)
1 /*	pass1.h	4.2	85/08/22	*/
2 
3 #ifndef _PASS1_
4 #define	_PASS1_
5 
6 #include "macdefs.h"
7 #include "manifest.h"
8 
9 /*
10  * Symbol table definition.
11  *
12  * Colliding entries are moved down with a standard
13  * probe (no quadratic rehash here) and moved back when
14  * entries are cleared.
15  */
16 struct	symtab {
17 #ifndef FLEXNAMES
18 	char	sname[NCHNAM];
19 #else
20 	char	*sname;
21 #endif
22 	struct	symtab *snext;	/* link to other symbols in the same scope */
23 	TWORD	stype;		/* type word */
24 	char	sclass;		/* storage class */
25 	char	slevel;		/* scope level */
26 	char	sflags;		/* flags, see below */
27 	int	offset;		/* offset or value */
28 	short	dimoff;		/* offset into the dimension table */
29 	short	sizoff;		/* offset into the size table */
30 	int	suse;		/* line number of last use of the variable */
31 };
32 
33 /*
34  * Storage classes
35  */
36 #define SNULL		0		/* initial value */
37 #define AUTO		1		/* automatic (on stack) */
38 #define EXTERN		2		/* external reference */
39 #define STATIC		3		/* static scope */
40 #define REGISTER	4		/* register requested */
41 #define EXTDEF		5		/* external definition */
42 #define LABEL		6		/* label definition */
43 #define ULABEL		7		/* undefined label reference */
44 #define MOS		8		/* member of structure */
45 #define PARAM		9		/* parameter */
46 #define STNAME		10		/* structure name */
47 #define MOU		11		/* member of union */
48 #define UNAME		12		/* union name */
49 #define TYPEDEF		13		/* typedef name */
50 #define FORTRAN		14		/* fortran function */
51 #define ENAME		15		/* enumeration name */
52 #define MOE		16		/* member of enumeration */
53 #define UFORTRAN 	17		/* undefined fortran reference */
54 #define USTATIC		18		/* undefined static reference */
55 
56 /* field size is ORed in */
57 #define FIELD		0100
58 #define FLDSIZ		077
59 #ifndef BUG1
60 extern	char *scnames();
61 #endif
62 
63 /*
64  * Symbol table flags
65  */
66 #define SMOS		01		/* member of structure */
67 #define SHIDDEN		02		/* hidden in current scope */
68 #define SHIDES		04		/* hides symbol in outer scope */
69 #define SSET		010		/* symbol assigned to */
70 #define SREF		020		/* symbol referenced */
71 #define SNONUNIQ	040		/* non-unique structure member */
72 #define STAG		0100		/* structure tag name */
73 
74 /*
75  * Location counters
76  */
77 #define PROG		0		/* program segment */
78 #define DATA		1		/* data segment */
79 #define ADATA		2		/* array data segment */
80 #define STRNG		3		/* string data segment */
81 #define ISTRNG		4		/* initialized string segment */
82 #define STAB		5		/* symbol table segment */
83 
84 
85 #ifndef ONEPASS
86 #include "ndu.h"
87 #endif
88 
89 
90 #ifndef FIXDEF
91 #define FIXDEF(p)
92 #endif
93 #ifndef FIXARG
94 #define FIXARG(p)
95 #endif
96 #ifndef FIXSTRUCT
97 #define FIXSTRUCT(a,b)
98 #endif
99 
100 	/* alignment of initialized quantities */
101 #ifndef AL_INIT
102 #define	AL_INIT ALINT
103 #endif
104 
105 /*
106  * External definitions
107  */
108 struct sw {		/* switch table */
109 	CONSZ	sval;	/* case value */
110 	int	slab;	/* associated label */
111 };
112 extern	struct sw swtab[];
113 extern	struct sw *swp;
114 extern	int swx;
115 
116 extern	int ftnno;
117 extern	int blevel;
118 extern	int instruct, stwart;
119 
120 extern	int lineno, nerrors;
121 
122 extern	CONSZ lastcon;
123 extern	float fcon;
124 extern	double dcon;
125 
126 extern	char ftitle[];
127 extern	char ititle[];
128 extern	struct symtab stab[];
129 extern	int curftn;
130 extern	int curclass;
131 extern	int curdim;
132 extern	int dimtab[];
133 extern	int paramstk[];
134 extern	int paramno;
135 extern	int autooff, argoff, strucoff;
136 extern	int regvar;
137 extern	int minrvar;
138 extern	int brkflag;
139 typedef union {
140 	int intval;
141 	NODE * nodep;
142 	} YYSTYPE;
143 extern	YYSTYPE yylval;
144 extern	char yytext[];
145 
146 extern	int strflg;
147 
148 extern	OFFSZ inoff;
149 
150 extern	int reached;
151 
152 /* tunnel to buildtree for name id's */
153 extern	int idname;
154 
155 extern	NODE node[];
156 extern	NODE *lastfree;
157 
158 extern	int cflag, hflag, pflag;
159 
160 /* various labels */
161 extern	int brklab;
162 extern	int contlab;
163 extern	int flostat;
164 extern	int retlab;
165 extern	int retstat;
166 extern	int asavbc[], *psavbc;
167 
168 /* declarations of various functions */
169 extern	NODE
170 	*buildtree(),
171 	*bdty(),
172 	*mkty(),
173 	*rstruct(),
174 	*dclstruct(),
175 	*getstr(),
176 	*tymerge(),
177 	*stref(),
178 	*offcon(),
179 	*bcon(),
180 	*bpsize(),
181 	*convert(),
182 	*pconvert(),
183 	*oconvert(),
184 	*ptmatch(),
185 	*tymatch(),
186 	*makety(),
187 	*block(),
188 	*doszof(),
189 	*talloc(),
190 	*optim(),
191 	*fixargs(),
192 	*clocal();
193 OFFSZ	tsize(),
194 	psize();
195 TWORD	types();
196 double	atof();
197 char	*exname(), *exdcon();
198 
199 #define checkst(x)
200 
201 #ifndef CHARCAST
202 /* to make character constants into character connstants */
203 /* this is a macro to defend against cross-compilers, etc. */
204 #define CHARCAST(x) (char)(x)
205 #endif
206 #endif
207 
208 /*
209  * Flags used in structures/unions
210  */
211 #define SEENAME		01
212 #define INSTRUCT	02
213 #define INUNION		04
214 #define FUNNYNAME	010
215 #define TAGNAME		020
216 
217 /*
218  * Flags used in the (elementary) flow analysis ...
219  */
220 #define FBRK		02
221 #define FCONT		04
222 #define FDEF		010
223 #define FLOOP		020
224 
225 /*
226  * Flags used for return status
227  */
228 #define RETVAL		1
229 #define NRETVAL		2
230 
231 #define NONAME		040000		/* marks constant w/o name field */
232 #define NOOFFSET	(-10201)	/* mark an offset which is undefined */
233 
234