xref: /original-bsd/usr.bin/f77/pass1.tahoe/defs.h (revision 21439bbc)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)defs.h	5.1 (Berkeley) 6/7/85
7  */
8 
9 /*
10  * defs.h
11  *
12  * Definitions for f77pass1
13  *
14  * University of Utah CS Dept modification history:
15  *
16  * $Header: defs.h,v 2.3 85/06/07 21:06:48 root Exp $
17  * $Log:	defs.h,v $
18  * Revision 2.3  85/06/07  21:06:48  root
19  * Add copyright
20  *
21  * Revision 2.2  85/01/11  21:02:58  donn
22  * Added 'issaved' bit to addrblocks to help implement SAVE statements.
23  *
24  * Revision 2.1  84/07/19  12:02:46  donn
25  * Changed comment headers for UofU.
26  *
27  * Revision 1.2  84/02/27  00:49:40  donn
28  * Added external references to lists of argument temporaries, used in the
29  * Berkeley changes to reduce offsets of data.
30  *
31  */
32 
33 #include <stdio.h>
34 
35 #ifdef unix
36 #	include <ctype.h>
37 #endif
38 
39 #include "ftypes.h"
40 #include "defines.h"
41 #include "machdefs.h"
42 
43 #define VL 16
44 
45 #define MAXDIM 20
46 #define MAXINCLUDES 10
47 #define MAXLITERALS 30
48 #define MAXCTL 20
49 #define MAXHASH 1009
50 #define MAXSTNO 401
51 #define MAXEXT 200
52 #define MAXEQUIV 150
53 #define MAXLABLIST 256
54 #define MAXDEBUGFLAG 20
55 
56 typedef union Expression *expptr;
57 typedef union Taggedblock *tagptr;
58 typedef struct Chain *chainp;
59 typedef struct Addrblock *Addrp;
60 typedef struct Tempblock *Tempp;
61 typedef struct Constblock *Constp;
62 typedef struct Exprblock *Exprp;
63 typedef struct Nameblock *Namep;
64 
65 extern FILEP infile;
66 extern FILEP diagfile;
67 extern FILEP textfile;
68 extern FILEP asmfile;
69 extern FILEP initfile;
70 extern long int headoffset;
71 
72 extern char token [ ];
73 extern int toklen;
74 extern int lineno;
75 extern char *infname;
76 extern int needkwd;
77 extern struct Labelblock *thislabel;
78 
79 extern int maxctl;
80 extern int maxequiv;
81 extern int maxstno;
82 extern int maxhash;
83 extern int maxext;
84 
85 extern flag profileflag;
86 extern flag optimflag;
87 extern flag nowarnflag;
88 extern flag ftn66flag;
89 extern flag no66flag;
90 extern flag noextflag;
91 extern flag shiftcase;
92 extern flag undeftype;
93 extern flag shortsubs;
94 extern flag onetripflag;
95 extern flag checksubs;
96 extern flag debugflag[];
97 extern flag equivdcl;
98 extern int nerr;
99 extern int nwarn;
100 extern int ndata;
101 
102 extern int parstate;
103 extern flag headerdone;
104 extern int blklevel;
105 extern flag saveall;
106 extern flag substars;
107 extern int impltype[ ];
108 extern int implleng[ ];
109 extern int implstg[ ];
110 
111 extern int tyint;
112 extern int tylogical;
113 extern ftnint typesize[];
114 extern int typealign[];
115 extern int procno;
116 extern int proctype;
117 extern char * procname;
118 extern int rtvlabel[ ];
119 extern int fudgelabel;	/* to confuse the pdp11 optimizer */
120 extern Addrp typeaddr;
121 extern Addrp retslot;
122 extern int cxslot;
123 extern int chslot;
124 extern int chlgslot;
125 extern int procclass;
126 extern ftnint procleng;
127 extern int nentry;
128 extern flag multitype;
129 extern int blklevel;
130 extern int lastlabno;
131 extern int lastvarno;
132 extern int lastargslot;
133 extern int argloc;
134 extern ftnint autoleng;
135 extern ftnint bssleng;
136 extern int retlabel;
137 extern int ret0label;
138 extern int dorange;
139 extern int regnum[ ];
140 extern Namep regnamep[ ];
141 extern int maxregvar;
142 extern int highregvar;
143 extern int nregvar;
144 extern ftnint lowbss;
145 extern ftnint highbss;
146 extern int bsslabel;
147 extern flag anyinits;
148 extern flag anylocals;
149 
150 extern chainp templist;
151 extern chainp argtemplist;
152 extern chainp activearglist;
153 extern int maxdim;
154 extern chainp holdtemps;
155 extern struct Entrypoint *entries;
156 extern struct Rplblock *rpllist;
157 extern struct Chain *curdtp;
158 extern ftnint curdtelt;
159 extern flag toomanyinit;
160 
161 extern flag inioctl;
162 extern int iostmt;
163 extern Addrp ioblkp;
164 extern int nioctl;
165 extern int nequiv;
166 extern int eqvstart;	/* offset to eqv number to guarantee uniqueness */
167 extern int nintnames;
168 
169 #ifdef SDB
170 extern int dbglabel;
171 extern flag sdbflag;
172 #endif
173 
174 extern int cdatafile;
175 extern int cchkfile;
176 extern int vdatafile;
177 extern int vchkfile;
178 
179 extern char cdatafname[];
180 extern char cchkfname[];
181 extern char vdatafname[];
182 extern char vchkfname[];
183 
184 extern long cdatahwm;
185 extern long vdatahwm;
186 
187 
188 struct Chain
189 	{
190 	chainp nextp;
191 	tagptr datap;
192 	};
193 
194 extern chainp chains;
195 
196 struct Headblock
197 	{
198 	field tag;
199 	field vtype;
200 	field vclass;
201 	field vstg;
202 	expptr vleng;
203 	} ;
204 
205 struct Ctlframe
206 	{
207 	unsigned ctltype:8;
208 	unsigned dostepsign:8;
209 	int ctlabels[4];
210 	int dolabel;
211 	Namep donamep;
212 	expptr domax;
213 	expptr dostep;
214 	};
215 #define endlabel ctlabels[0]
216 #define elselabel ctlabels[1]
217 #define dobodylabel ctlabels[1]
218 #define doposlabel ctlabels[2]
219 #define doneglabel ctlabels[3]
220 extern struct Ctlframe *ctls;
221 extern struct Ctlframe *ctlstack;
222 extern struct Ctlframe *lastctl;
223 
224 struct Extsym
225 	{
226 	char extname[XL+1];
227 	field extstg;
228 	unsigned extsave:1;
229 	unsigned extinit:1;
230 	chainp extp;
231 	ftnint extleng;
232 	ftnint maxleng;
233 	char init;
234 	long initoffset;
235 	};
236 
237 extern struct Extsym *extsymtab;
238 extern struct Extsym *nextext;
239 extern struct Extsym *lastext;
240 
241 struct Labelblock
242 	{
243 	int labelno;
244 	unsigned blklevel:8;
245 	unsigned labused:1;
246 	unsigned labinacc:1;
247 	unsigned labdefined:1;
248 	unsigned labtype:2;
249 	ftnint stateno;
250 	};
251 
252 extern struct Labelblock *labeltab;
253 extern struct Labelblock *labtabend;
254 extern struct Labelblock *highlabtab;
255 
256 struct Entrypoint
257 	{
258 	struct Entrypoint *entnextp;
259 	struct Extsym *entryname;
260 	chainp arglist;
261 	int entrylabel;
262 	int typelabel;
263 	Namep enamep;
264 	};
265 
266 struct Primblock
267 	{
268 	field tag;
269 	field vtype;
270 	Namep namep;
271 	struct Listblock *argsp;
272 	expptr fcharp;
273 	expptr lcharp;
274 	};
275 
276 
277 struct Hashentry
278 	{
279 	int hashval;
280 	Namep varp;
281 	};
282 extern struct Hashentry *hashtab;
283 extern struct Hashentry *lasthash;
284 
285 struct Intrpacked	/* bits for intrinsic function description */
286 	{
287 	unsigned f1:3;
288 	unsigned f2:4;
289 	unsigned f3:7;
290 	};
291 
292 struct Nameblock
293 	{
294 	field tag;
295 	field vtype;
296 	field vclass;
297 	field vstg;
298 	expptr vleng;
299 	char varname[VL];
300 	unsigned vdovar:1;
301 	unsigned vdcldone:1;
302 	unsigned vadjdim:1;
303 	unsigned vsave:1;
304 	unsigned vprocclass:3;
305 	unsigned vregno:4;
306 	union	{
307 		int varno;
308 		struct Intrpacked intrdesc;	/* bits for intrinsic function*/
309 		} vardesc;
310 	struct Dimblock *vdim;
311 	ftnint voffset;
312 	union	{
313 		chainp namelist;	/* points to chain of names in */
314 		chainp vstfdesc;	/* points to (formals, expr) pair */
315 		} varxptr;
316 	char inlcomm;
317 	char init;
318 	long initoffset;
319 	ftnint varsize;
320 	};
321 
322 
323 struct Paramblock
324 	{
325 	field tag;
326 	field vtype;
327 	field vclass;
328 	field vstg;
329 	expptr vleng;
330 	char varname[VL];
331 	expptr paramval;
332 	} ;
333 
334 
335 struct Exprblock
336 	{
337 	field tag;
338 	field vtype;
339 	field vclass;
340 	field vstg;
341 	expptr vleng;
342 	unsigned opcode:6;
343 	expptr leftp;
344 	expptr rightp;
345 	};
346 
347 
348 union Constant
349 	{
350 	char *ccp;
351 	ftnint ci;
352 	double cd[2];
353 	};
354 
355 struct Constblock
356 	{
357 	field tag;
358 	field vtype;
359 	field vclass;
360 	field vstg;
361 	expptr vleng;
362 	union Constant constant;
363 	};
364 
365 
366 struct Listblock
367 	{
368 	field tag;
369 	field vtype;
370 	chainp listp;
371 	};
372 
373 
374 
375 struct Addrblock
376 	{
377 	field tag;
378 	field vtype;
379 	field vclass;
380 	field vstg;
381 	expptr vleng;
382 	int memno;
383 	expptr memoffset;
384 	unsigned istemp:1;
385         unsigned isarray:1;
386 	unsigned issaved:1;
387 	unsigned ntempelt:10;
388 	ftnint varleng;
389 	ftnint varsize;
390 	};
391 
392 
393 
394 struct Tempblock
395 	{
396 	field tag;
397 	field vtype;
398 	field vclass;
399 	expptr vleng;
400 	Addrp memalloc;
401 	unsigned istemp:1;
402 	unsigned ntempelt:10;
403 	ftnint varleng;
404 	};
405 
406 
407 
408 struct Errorblock
409 	{
410 	field tag;
411 	field vtype;
412 	};
413 
414 
415 union Expression
416 	{
417 	field tag;
418 	struct Headblock headblock;
419 	struct Exprblock exprblock;
420 	struct Addrblock addrblock;
421 	struct Tempblock tempblock;
422 	struct Constblock constblock;
423 	struct Errorblock errorblock;
424 	struct Listblock listblock;
425 	struct Primblock primblock;
426 	} ;
427 
428 
429 
430 struct Dimblock
431 	{
432 	int ndim;
433 	expptr nelt;
434 	expptr baseoffset;
435 	expptr basexpr;
436 	struct
437 		{
438 		expptr dimsize;
439 		expptr dimexpr;
440 		expptr lb;
441 		expptr lbaddr;
442 		expptr ub;
443 		expptr ubaddr;
444 		} dims[1];
445 	};
446 
447 
448 struct Impldoblock
449 	{
450 	field tag;
451 	unsigned isactive:1;
452 	unsigned isbusy:1;
453 	Namep varnp;
454 	Constp varvp;
455 	chainp impdospec;
456 	expptr implb;
457 	expptr impub;
458 	expptr impstep;
459 	ftnint impdiff;
460 	ftnint implim;
461 	struct Chain *datalist;
462 	};
463 
464 
465 struct Rplblock	/* name replacement block */
466 	{
467 	struct Rplblock *rplnextp;
468 	Namep rplnp;
469 	expptr rplvp;
470 	expptr rplxp;
471 	int rpltag;
472 	};
473 
474 
475 
476 struct Equivblock
477 	{
478 	struct Eqvchain *equivs;
479 	flag eqvinit;
480 	long int eqvtop;
481 	long int eqvbottom;
482 	char inlcomm;
483 	char init;
484 	long initoffset;
485 	} ;
486 #define eqvleng eqvtop
487 
488 extern struct Equivblock *eqvclass;
489 
490 
491 struct Eqvchain
492 	{
493 	struct Eqvchain *eqvnextp;
494 	union
495 		{
496 		struct Primblock *eqvlhs;
497 		Namep eqvname;
498 		} eqvitem;
499 	long int eqvoffset;
500 	} ;
501 
502 
503 union Taggedblock
504 	{
505 	field tag;
506 	struct Headblock headblock;
507 	struct Nameblock nameblock;
508 	struct Paramblock paramblock;
509 	struct Exprblock exprblock;
510 	struct Constblock constblock;
511 	struct Listblock listblock;
512 	struct Addrblock addrblock;
513 	struct Tempblock tempblock;
514 	struct Errorblock errorblock;
515 	struct Primblock primblock;
516 	struct Impldoblock impldoblock;
517 	} ;
518 
519 
520 
521 
522 struct Literal
523 	{
524 	short littype;
525 	short litnum;
526 	union	{
527 		ftnint litival;
528 		double litdval;
529 		struct	{
530 			char litclen;	/* small integer */
531 			char litcstr[XL];
532 			} litcval;
533 		} litval;
534 	};
535 
536 extern struct Literal litpool[ ];
537 extern int nliterals;
538 
539 
540 
541 /* popular functions with non integer return values */
542 
543 
544 int *ckalloc();
545 char *varstr(), *nounder(), *varunder();
546 char *copyn(), *copys();
547 chainp hookup(), mkchain();
548 ftnint convci();
549 char *convic();
550 char *setdoto();
551 double convcd();
552 Namep mkname();
553 struct Labelblock *mklabel(), *execlab();
554 struct Extsym *mkext(), *newentry();
555 expptr addrof(), call1(), call2(), call3(), call4();
556 Tempp mktmpn();
557 Addrp builtin(), mktemp(), altmpn(), mkaltemp(), mkaltmpn(), autovar();
558 Addrp mkplace(), mkaddr(), putconst(), memversion();
559 expptr mkprim(), mklhs(), mkexpr(), mkconv(), mkfunct(), fixexpr(), fixtype();
560 expptr errnode(), mkintcon();
561 tagptr cpexpr();
562 ftnint lmin(), lmax(), iarrlen();
563