xref: /original-bsd/old/pcc/mip/mfile1 (revision e59fb703)
1/*	@(#)mfile1	4.3	(Berkeley)	85/01/18	*/
2
3# include "macdefs"
4# include "manifest"
5
6/*	storage classes  */
7# define SNULL 0
8# define AUTO 1
9# define EXTERN 2
10# define STATIC 3
11# define REGISTER 4
12# define EXTDEF 5
13# define LABEL 6
14# define ULABEL 7
15# define MOS 8
16# define PARAM 9
17# define STNAME 10
18# define MOU 11
19# define UNAME 12
20# define TYPEDEF 13
21# define FORTRAN 14
22# define ENAME 15
23# define MOE 16
24# define UFORTRAN 17
25# define USTATIC 18
26	/* field size is ORed in */
27# define FIELD 0100
28# define FLDSIZ 077
29# ifndef BUG1
30extern char *scnames();
31# endif
32
33/*	location counters */
34# define PROG 0
35# define DATA 1
36# define ADATA 2
37# define STRNG 3
38# define ISTRNG 4
39# define STAB 5
40
41
42/* symbol table flags */
43# define SMOS 01
44# define SHIDDEN 02
45# define SHIDES 04
46# define SSET 010
47# define SREF 020
48# define SNONUNIQ 040
49# define STAG 0100
50
51# ifndef FIXDEF
52# define FIXDEF(p)
53#endif
54# ifndef FIXARG
55# define FIXARG(p)
56# endif
57# ifndef FIXSTRUCT
58# define FIXSTRUCT(a,b)
59# endif
60
61	/* alignment of initialized quantities */
62# ifndef AL_INIT
63#	define	AL_INIT ALINT
64# endif
65
66struct symtab {
67#ifndef FLEXNAMES
68	char sname[NCHNAM];
69#else
70	char *sname;
71#endif
72	TWORD stype;  /* type word */
73
74	char sclass;  /* storage class */
75	char slevel;  /* scope level */
76	char sflags;  /* flags for set, use, hidden, mos, etc. */
77	int offset;  /* offset or value */
78	short dimoff; /* offset into the dimension table */
79	short sizoff; /* offset into the size table */
80	short suse;  /* line number of last use of the variable */
81	};
82
83
84# ifdef ONEPASS
85/* NOPREF must be defined for use in first pass tree machine */
86# define NOPREF 020000  /* no preference for register assignment */
87#else
88
89union ndu {
90	struct {
91		int op;
92		TWORD type;
93		int cdim, csiz;
94		}fn; /* front node */
95	struct {
96		int op;
97		TWORD type;
98		int cdim, csiz;
99		NODE *left;
100		NODE * right;
101		}in; /* interior node */
102
103	struct {
104		/* this structure is the same as above,
105		   but is used when a value, rather than
106		   address, is kept in +left */
107		int op;
108		TWORD type;
109		int cdim, csiz;
110		CONSZ lval;
111		int rval;
112		}tn; /* terminal node */
113
114	struct {
115		/* this structure is used when a single precision constant
116		   is being computed */
117		int op;
118		TWORD type;
119		int cdim, csiz;
120		float fval;
121		}fpn; /* FCON node */
122
123	struct {
124		/* this structure is used when a double precision constant
125		   is being computed */
126		int op;
127		TWORD type;
128		int cdim, csiz;
129		double dval;
130		}dpn; /* DCON node */
131
132	};
133# endif
134
135struct sw {
136	CONSZ sval;
137	int slab;
138	};
139
140extern struct sw swtab[];
141extern struct sw *swp;
142extern int swx;
143
144extern int ftnno;
145extern int blevel;
146extern int instruct, stwart;
147
148extern int lineno, nerrors;
149typedef union {
150	int intval;
151	NODE * nodep;
152	} YYSTYPE;
153extern YYSTYPE yylval;
154
155extern CONSZ lastcon;
156extern float fcon;
157extern double dcon;
158
159extern char ftitle[];
160extern char ititle[];
161extern struct symtab stab[];
162extern int curftn;
163extern int curclass;
164extern int curdim;
165extern int dimtab[];
166extern int paramstk[];
167extern int paramno;
168extern int autooff, argoff, strucoff;
169extern int regvar;
170extern int minrvar;
171extern int brkflag;
172extern char yytext[];
173
174extern int strflg;
175
176extern OFFSZ inoff;
177
178extern int reached;
179
180/*	tunnel to buildtree for name id's */
181
182extern int idname;
183
184extern NODE node[];
185extern NODE *lastfree;
186
187extern int cflag, hflag, pflag;
188
189/* various labels */
190extern int brklab;
191extern int contlab;
192extern int flostat;
193extern int retlab;
194extern int retstat;
195extern int asavbc[], *psavbc;
196
197/*	flags used in structures/unions */
198
199# define SEENAME 01
200# define INSTRUCT 02
201# define INUNION 04
202# define FUNNYNAME 010
203# define TAGNAME 020
204
205/*	flags used in the (elementary) flow analysis ... */
206
207# define FBRK 02
208# define FCONT 04
209# define FDEF 010
210# define FLOOP 020
211
212/*	flags used for return status */
213
214# define RETVAL 1
215# define NRETVAL 2
216
217/*	used to mark a constant with no name field */
218
219# define NONAME 040000
220
221	/* mark an offset which is undefined */
222
223# define NOOFFSET (-10201)
224
225/*	declarations of various functions */
226
227extern NODE
228	*buildtree(),
229	*bdty(),
230	*mkty(),
231	*rstruct(),
232	*dclstruct(),
233	*getstr(),
234	*tymerge(),
235	*stref(),
236	*offcon(),
237	*bcon(),
238	*bpsize(),
239	*convert(),
240	*pconvert(),
241	*oconvert(),
242	*ptmatch(),
243	*tymatch(),
244	*makety(),
245	*block(),
246	*doszof(),
247	*talloc(),
248	*optim(),
249	*fixargs(),
250	*clocal();
251
252OFFSZ	tsize(),
253	psize();
254
255TWORD	types();
256
257
258double atof();
259
260char *exname(), *exdcon();
261
262# define checkst(x)
263
264# ifndef CHARCAST
265/* to make character constants into character connstants */
266/* this is a macro to defend against cross-compilers, etc. */
267# define CHARCAST(x) (char)(x)
268# endif
269
270# define BCSZ 100 /* size of the table to save break and continue labels */
271# define SYMTSZ 3000 /* size of the symbol table (was 500) */
272# define DIMTABSZ 4200 /* size of the dimension/size table (was 800) */
273# define PARAMSZ 300 /* size of the parameter stack */
274# define SWITSZ 500 /* size of switch table */
275/*	special interfaces for yacc alone */
276/*	These serve as abbreviations of 2 or more ops:
277	ASOP	=, = ops
278	RELOP	LE,LT,GE,GT
279	EQUOP	EQ,NE
280	DIVOP	DIV,MOD
281	SHIFTOP	LS,RS
282	ICOP	ICR,DECR
283	UNOP	NOT,COMPL
284	STROP	DOT,STREF
285
286	*/
287# define ASOP 28
288# define RELOP 29
289# define EQUOP 30
290# define DIVOP 31
291# define SHIFTOP 32
292# define INCOP 33
293# define UNOP 34
294# define STROP 35
295
296# define LP 53
297# define RP 54
298# define LC 55
299# define RC 56
300