xref: /csrg-svn/usr.bin/f77/pass1.tahoe/defs.h (revision 46303)
143206Sbostic /*
243206Sbostic  * Copyright (c) 1980 Regents of the University of California.
343206Sbostic  * All rights reserved.  The Berkeley software License Agreement
443206Sbostic  * specifies the terms and conditions for redistribution.
543206Sbostic  *
643206Sbostic  *	@(#)defs.h	5.1 (Berkeley) 6/7/85
743206Sbostic  */
843206Sbostic 
943206Sbostic /*
1043206Sbostic  * defs.h
1143206Sbostic  *
1243206Sbostic  * Definitions for f77pass1
1343206Sbostic  *
1443206Sbostic  * University of Utah CS Dept modification history:
1543206Sbostic  *
1643206Sbostic  * $Header: defs.h,v 2.3 85/06/07 21:06:48 root Exp $
1743206Sbostic  * $Log:	defs.h,v $
1843206Sbostic  * Revision 2.3  85/06/07  21:06:48  root
1943206Sbostic  * Add copyright
2043206Sbostic  *
2143206Sbostic  * Revision 2.2  85/01/11  21:02:58  donn
2243206Sbostic  * Added 'issaved' bit to addrblocks to help implement SAVE statements.
2343206Sbostic  *
2443206Sbostic  * Revision 2.1  84/07/19  12:02:46  donn
2543206Sbostic  * Changed comment headers for UofU.
2643206Sbostic  *
2743206Sbostic  * Revision 1.2  84/02/27  00:49:40  donn
2843206Sbostic  * Added external references to lists of argument temporaries, used in the
2943206Sbostic  * Berkeley changes to reduce offsets of data.
3043206Sbostic  *
3143206Sbostic  */
3243206Sbostic 
3343206Sbostic #include <stdio.h>
3443206Sbostic 
3543206Sbostic #ifdef unix
3643206Sbostic #	include <ctype.h>
3743206Sbostic #endif
3843206Sbostic 
3943206Sbostic #include "ftypes.h"
4043206Sbostic #include "defines.h"
4143206Sbostic #include "machdefs.h"
4243206Sbostic 
4343206Sbostic #define VL 16
4443206Sbostic 
4543206Sbostic #define MAXDIM 20
4643206Sbostic #define MAXINCLUDES 10
4743206Sbostic #define MAXLITERALS 30
4843206Sbostic #define MAXCTL 20
4943206Sbostic #define MAXHASH 1009
5043206Sbostic #define MAXSTNO 401
5143206Sbostic #define MAXEXT 200
5243206Sbostic #define MAXEQUIV 150
5343206Sbostic #define MAXLABLIST 256
5443206Sbostic #define MAXDEBUGFLAG 20
5543206Sbostic 
5643206Sbostic typedef union Expression *expptr;
5743206Sbostic typedef union Taggedblock *tagptr;
5843206Sbostic typedef struct Chain *chainp;
5943206Sbostic typedef struct Addrblock *Addrp;
6043206Sbostic typedef struct Tempblock *Tempp;
6143206Sbostic typedef struct Constblock *Constp;
6243206Sbostic typedef struct Exprblock *Exprp;
6343206Sbostic typedef struct Nameblock *Namep;
6443206Sbostic 
6543206Sbostic extern FILEP infile;
6643206Sbostic extern FILEP diagfile;
6743206Sbostic extern FILEP textfile;
6843206Sbostic extern FILEP asmfile;
6943206Sbostic extern FILEP initfile;
7043206Sbostic extern long int headoffset;
7143206Sbostic 
7243206Sbostic extern char token [ ];
7343206Sbostic extern int toklen;
7443206Sbostic extern int lineno;
7543206Sbostic extern char *infname;
7643206Sbostic extern int needkwd;
7743206Sbostic extern struct Labelblock *thislabel;
7843206Sbostic 
7943206Sbostic extern int maxctl;
8043206Sbostic extern int maxequiv;
8143206Sbostic extern int maxstno;
8243206Sbostic extern int maxhash;
8343206Sbostic extern int maxext;
8443206Sbostic 
8543206Sbostic extern flag profileflag;
8643206Sbostic extern flag optimflag;
8743206Sbostic extern flag nowarnflag;
8843206Sbostic extern flag ftn66flag;
8943206Sbostic extern flag no66flag;
9043206Sbostic extern flag noextflag;
9143206Sbostic extern flag shiftcase;
9243206Sbostic extern flag undeftype;
9343206Sbostic extern flag shortsubs;
9443206Sbostic extern flag onetripflag;
9543206Sbostic extern flag checksubs;
9643206Sbostic extern flag debugflag[];
9743206Sbostic extern flag equivdcl;
9843206Sbostic extern int nerr;
9943206Sbostic extern int nwarn;
10043206Sbostic extern int ndata;
10143206Sbostic 
10243206Sbostic extern int parstate;
10343206Sbostic extern flag headerdone;
10443206Sbostic extern int blklevel;
10543206Sbostic extern flag saveall;
10643206Sbostic extern flag substars;
10743206Sbostic extern int impltype[ ];
10843206Sbostic extern int implleng[ ];
10943206Sbostic extern int implstg[ ];
11043206Sbostic 
11143206Sbostic extern int tyint;
11243206Sbostic extern int tylogical;
11343206Sbostic extern ftnint typesize[];
11443206Sbostic extern int typealign[];
11543206Sbostic extern int procno;
11643206Sbostic extern int proctype;
11743206Sbostic extern char * procname;
11843206Sbostic extern int rtvlabel[ ];
11943206Sbostic extern int fudgelabel;	/* to confuse the pdp11 optimizer */
12043206Sbostic extern Addrp typeaddr;
12143206Sbostic extern Addrp retslot;
12243206Sbostic extern int cxslot;
12343206Sbostic extern int chslot;
12443206Sbostic extern int chlgslot;
12543206Sbostic extern int procclass;
12643206Sbostic extern ftnint procleng;
12743206Sbostic extern int nentry;
12843206Sbostic extern flag multitype;
12943206Sbostic extern int blklevel;
13043206Sbostic extern int lastlabno;
13143206Sbostic extern int lastvarno;
13243206Sbostic extern int lastargslot;
13343206Sbostic extern int argloc;
13443206Sbostic extern ftnint autoleng;
13543206Sbostic extern ftnint bssleng;
13643206Sbostic extern int retlabel;
13743206Sbostic extern int ret0label;
13843206Sbostic extern int dorange;
13943206Sbostic extern int regnum[ ];
14043206Sbostic extern Namep regnamep[ ];
14143206Sbostic extern int maxregvar;
14243206Sbostic extern int highregvar;
14343206Sbostic extern int nregvar;
14443206Sbostic extern ftnint lowbss;
14543206Sbostic extern ftnint highbss;
14643206Sbostic extern int bsslabel;
14743206Sbostic extern flag anyinits;
14843206Sbostic extern flag anylocals;
14943206Sbostic 
15043206Sbostic extern chainp templist;
15143206Sbostic extern chainp argtemplist;
15243206Sbostic extern chainp activearglist;
15343206Sbostic extern int maxdim;
15443206Sbostic extern chainp holdtemps;
15543206Sbostic extern struct Entrypoint *entries;
15643206Sbostic extern struct Rplblock *rpllist;
15743206Sbostic extern struct Chain *curdtp;
15843206Sbostic extern ftnint curdtelt;
15943206Sbostic extern flag toomanyinit;
16043206Sbostic 
16143206Sbostic extern flag inioctl;
16243206Sbostic extern int iostmt;
16343206Sbostic extern Addrp ioblkp;
16443206Sbostic extern int nioctl;
16543206Sbostic extern int nequiv;
16643206Sbostic extern int eqvstart;	/* offset to eqv number to guarantee uniqueness */
16743206Sbostic extern int nintnames;
16843206Sbostic 
16943206Sbostic #ifdef SDB
17043206Sbostic extern int dbglabel;
17143206Sbostic extern flag sdbflag;
17243206Sbostic #endif
17343206Sbostic 
17443206Sbostic extern int cdatafile;
17543206Sbostic extern int cchkfile;
17643206Sbostic extern int vdatafile;
17743206Sbostic extern int vchkfile;
17843206Sbostic 
17943206Sbostic extern char cdatafname[];
18043206Sbostic extern char cchkfname[];
18143206Sbostic extern char vdatafname[];
18243206Sbostic extern char vchkfname[];
18343206Sbostic 
18443206Sbostic extern long cdatahwm;
18543206Sbostic extern long vdatahwm;
18643206Sbostic 
18743206Sbostic 
18843206Sbostic struct Chain
18943206Sbostic 	{
19043206Sbostic 	chainp nextp;
19143206Sbostic 	tagptr datap;
19243206Sbostic 	};
19343206Sbostic 
19443206Sbostic extern chainp chains;
19543206Sbostic 
19643206Sbostic struct Headblock
19743206Sbostic 	{
19843206Sbostic 	field tag;
19943206Sbostic 	field vtype;
20043206Sbostic 	field vclass;
20143206Sbostic 	field vstg;
20243206Sbostic 	expptr vleng;
20343206Sbostic 	} ;
20443206Sbostic 
20543206Sbostic struct Ctlframe
20643206Sbostic 	{
20743206Sbostic 	unsigned ctltype:8;
20843206Sbostic 	unsigned dostepsign:8;
20943206Sbostic 	int ctlabels[4];
21043206Sbostic 	int dolabel;
21143206Sbostic 	Namep donamep;
21243206Sbostic 	expptr domax;
21343206Sbostic 	expptr dostep;
21443206Sbostic 	};
21543206Sbostic #define endlabel ctlabels[0]
21643206Sbostic #define elselabel ctlabels[1]
21743206Sbostic #define dobodylabel ctlabels[1]
21843206Sbostic #define doposlabel ctlabels[2]
21943206Sbostic #define doneglabel ctlabels[3]
22043206Sbostic extern struct Ctlframe *ctls;
22143206Sbostic extern struct Ctlframe *ctlstack;
22243206Sbostic extern struct Ctlframe *lastctl;
22343206Sbostic 
22443206Sbostic struct Extsym
22543206Sbostic 	{
22643206Sbostic 	char extname[XL+1];
22743206Sbostic 	field extstg;
22843206Sbostic 	unsigned extsave:1;
22943206Sbostic 	unsigned extinit:1;
23043206Sbostic 	chainp extp;
23143206Sbostic 	ftnint extleng;
23243206Sbostic 	ftnint maxleng;
23343206Sbostic 	char init;
23443206Sbostic 	long initoffset;
23543206Sbostic 	};
23643206Sbostic 
23743206Sbostic extern struct Extsym *extsymtab;
23843206Sbostic extern struct Extsym *nextext;
23943206Sbostic extern struct Extsym *lastext;
24043206Sbostic 
24143206Sbostic struct Labelblock
24243206Sbostic 	{
24343206Sbostic 	int labelno;
24443206Sbostic 	unsigned blklevel:8;
24543206Sbostic 	unsigned labused:1;
24643206Sbostic 	unsigned labinacc:1;
24743206Sbostic 	unsigned labdefined:1;
24843206Sbostic 	unsigned labtype:2;
24943206Sbostic 	ftnint stateno;
25043206Sbostic 	};
25143206Sbostic 
25243206Sbostic extern struct Labelblock *labeltab;
25343206Sbostic extern struct Labelblock *labtabend;
25443206Sbostic extern struct Labelblock *highlabtab;
25543206Sbostic 
25643206Sbostic struct Entrypoint
25743206Sbostic 	{
25843206Sbostic 	struct Entrypoint *entnextp;
25943206Sbostic 	struct Extsym *entryname;
26043206Sbostic 	chainp arglist;
26143206Sbostic 	int entrylabel;
26243206Sbostic 	int typelabel;
26343206Sbostic 	Namep enamep;
26443206Sbostic 	};
26543206Sbostic 
26643206Sbostic struct Primblock
26743206Sbostic 	{
26843206Sbostic 	field tag;
26943206Sbostic 	field vtype;
27043206Sbostic 	Namep namep;
27143206Sbostic 	struct Listblock *argsp;
27243206Sbostic 	expptr fcharp;
27343206Sbostic 	expptr lcharp;
27443206Sbostic 	};
27543206Sbostic 
27643206Sbostic 
27743206Sbostic struct Hashentry
27843206Sbostic 	{
27943206Sbostic 	int hashval;
28043206Sbostic 	Namep varp;
28143206Sbostic 	};
28243206Sbostic extern struct Hashentry *hashtab;
28343206Sbostic extern struct Hashentry *lasthash;
28443206Sbostic 
28543206Sbostic struct Intrpacked	/* bits for intrinsic function description */
28643206Sbostic 	{
28743206Sbostic 	unsigned f1:3;
28843206Sbostic 	unsigned f2:4;
28943206Sbostic 	unsigned f3:7;
29043206Sbostic 	};
29143206Sbostic 
29243206Sbostic struct Nameblock
29343206Sbostic 	{
29443206Sbostic 	field tag;
29543206Sbostic 	field vtype;
29643206Sbostic 	field vclass;
29743206Sbostic 	field vstg;
29843206Sbostic 	expptr vleng;
29943206Sbostic 	char varname[VL];
30043206Sbostic 	unsigned vdovar:1;
30143206Sbostic 	unsigned vdcldone:1;
30243206Sbostic 	unsigned vadjdim:1;
30343206Sbostic 	unsigned vsave:1;
30443206Sbostic 	unsigned vprocclass:3;
30543206Sbostic 	unsigned vregno:4;
30643206Sbostic 	union	{
30743206Sbostic 		int varno;
30843206Sbostic 		struct Intrpacked intrdesc;	/* bits for intrinsic function*/
30943206Sbostic 		} vardesc;
31043206Sbostic 	struct Dimblock *vdim;
31143206Sbostic 	ftnint voffset;
31243206Sbostic 	union	{
31343206Sbostic 		chainp namelist;	/* points to chain of names in */
31443206Sbostic 		chainp vstfdesc;	/* points to (formals, expr) pair */
31543206Sbostic 		} varxptr;
31643206Sbostic 	char inlcomm;
31743206Sbostic 	char init;
31843206Sbostic 	long initoffset;
31943206Sbostic 	ftnint varsize;
32043206Sbostic 	};
32143206Sbostic 
32243206Sbostic 
32343206Sbostic struct Paramblock
32443206Sbostic 	{
32543206Sbostic 	field tag;
32643206Sbostic 	field vtype;
32743206Sbostic 	field vclass;
32843206Sbostic 	field vstg;
32943206Sbostic 	expptr vleng;
33043206Sbostic 	char varname[VL];
33143206Sbostic 	expptr paramval;
33243206Sbostic 	} ;
33343206Sbostic 
33443206Sbostic 
33543206Sbostic struct Exprblock
33643206Sbostic 	{
33743206Sbostic 	field tag;
33843206Sbostic 	field vtype;
33943206Sbostic 	field vclass;
34043206Sbostic 	field vstg;
34143206Sbostic 	expptr vleng;
34243206Sbostic 	unsigned opcode:6;
34343206Sbostic 	expptr leftp;
34443206Sbostic 	expptr rightp;
34543206Sbostic 	};
34643206Sbostic 
34743206Sbostic 
34843206Sbostic union Constant
34943206Sbostic 	{
35043206Sbostic 	char *ccp;
35143206Sbostic 	ftnint ci;
35243206Sbostic 	double cd[2];
35343206Sbostic 	};
35443206Sbostic 
35543206Sbostic struct Constblock
35643206Sbostic 	{
35743206Sbostic 	field tag;
35843206Sbostic 	field vtype;
35943206Sbostic 	field vclass;
36043206Sbostic 	field vstg;
36143206Sbostic 	expptr vleng;
362*46303Sbostic 	union Constant constant;
36343206Sbostic 	};
36443206Sbostic 
36543206Sbostic 
36643206Sbostic struct Listblock
36743206Sbostic 	{
36843206Sbostic 	field tag;
36943206Sbostic 	field vtype;
37043206Sbostic 	chainp listp;
37143206Sbostic 	};
37243206Sbostic 
37343206Sbostic 
37443206Sbostic 
37543206Sbostic struct Addrblock
37643206Sbostic 	{
37743206Sbostic 	field tag;
37843206Sbostic 	field vtype;
37943206Sbostic 	field vclass;
38043206Sbostic 	field vstg;
38143206Sbostic 	expptr vleng;
38243206Sbostic 	int memno;
38343206Sbostic 	expptr memoffset;
38443206Sbostic 	unsigned istemp:1;
38543206Sbostic         unsigned isarray:1;
38643206Sbostic 	unsigned issaved:1;
38743206Sbostic 	unsigned ntempelt:10;
38843206Sbostic 	ftnint varleng;
38943206Sbostic 	ftnint varsize;
39043206Sbostic 	};
39143206Sbostic 
39243206Sbostic 
39343206Sbostic 
39443206Sbostic struct Tempblock
39543206Sbostic 	{
39643206Sbostic 	field tag;
39743206Sbostic 	field vtype;
39843206Sbostic 	field vclass;
39943206Sbostic 	expptr vleng;
40043206Sbostic 	Addrp memalloc;
40143206Sbostic 	unsigned istemp:1;
40243206Sbostic 	unsigned ntempelt:10;
40343206Sbostic 	ftnint varleng;
40443206Sbostic 	};
40543206Sbostic 
40643206Sbostic 
40743206Sbostic 
40843206Sbostic struct Errorblock
40943206Sbostic 	{
41043206Sbostic 	field tag;
41143206Sbostic 	field vtype;
41243206Sbostic 	};
41343206Sbostic 
41443206Sbostic 
41543206Sbostic union Expression
41643206Sbostic 	{
41743206Sbostic 	field tag;
41843206Sbostic 	struct Headblock headblock;
41943206Sbostic 	struct Exprblock exprblock;
42043206Sbostic 	struct Addrblock addrblock;
42143206Sbostic 	struct Tempblock tempblock;
42243206Sbostic 	struct Constblock constblock;
42343206Sbostic 	struct Errorblock errorblock;
42443206Sbostic 	struct Listblock listblock;
42543206Sbostic 	struct Primblock primblock;
42643206Sbostic 	} ;
42743206Sbostic 
42843206Sbostic 
42943206Sbostic 
43043206Sbostic struct Dimblock
43143206Sbostic 	{
43243206Sbostic 	int ndim;
43343206Sbostic 	expptr nelt;
43443206Sbostic 	expptr baseoffset;
43543206Sbostic 	expptr basexpr;
43643206Sbostic 	struct
43743206Sbostic 		{
43843206Sbostic 		expptr dimsize;
43943206Sbostic 		expptr dimexpr;
44043206Sbostic 		expptr lb;
44143206Sbostic 		expptr lbaddr;
44243206Sbostic 		expptr ub;
44343206Sbostic 		expptr ubaddr;
44443206Sbostic 		} dims[1];
44543206Sbostic 	};
44643206Sbostic 
44743206Sbostic 
44843206Sbostic struct Impldoblock
44943206Sbostic 	{
45043206Sbostic 	field tag;
45143206Sbostic 	unsigned isactive:1;
45243206Sbostic 	unsigned isbusy:1;
45343206Sbostic 	Namep varnp;
45443206Sbostic 	Constp varvp;
45543206Sbostic 	chainp impdospec;
45643206Sbostic 	expptr implb;
45743206Sbostic 	expptr impub;
45843206Sbostic 	expptr impstep;
45943206Sbostic 	ftnint impdiff;
46043206Sbostic 	ftnint implim;
46143206Sbostic 	struct Chain *datalist;
46243206Sbostic 	};
46343206Sbostic 
46443206Sbostic 
46543206Sbostic struct Rplblock	/* name replacement block */
46643206Sbostic 	{
46743206Sbostic 	struct Rplblock *rplnextp;
46843206Sbostic 	Namep rplnp;
46943206Sbostic 	expptr rplvp;
47043206Sbostic 	expptr rplxp;
47143206Sbostic 	int rpltag;
47243206Sbostic 	};
47343206Sbostic 
47443206Sbostic 
47543206Sbostic 
47643206Sbostic struct Equivblock
47743206Sbostic 	{
47843206Sbostic 	struct Eqvchain *equivs;
47943206Sbostic 	flag eqvinit;
48043206Sbostic 	long int eqvtop;
48143206Sbostic 	long int eqvbottom;
48243206Sbostic 	char inlcomm;
48343206Sbostic 	char init;
48443206Sbostic 	long initoffset;
48543206Sbostic 	} ;
48643206Sbostic #define eqvleng eqvtop
48743206Sbostic 
48843206Sbostic extern struct Equivblock *eqvclass;
48943206Sbostic 
49043206Sbostic 
49143206Sbostic struct Eqvchain
49243206Sbostic 	{
49343206Sbostic 	struct Eqvchain *eqvnextp;
49443206Sbostic 	union
49543206Sbostic 		{
49643206Sbostic 		struct Primblock *eqvlhs;
49743206Sbostic 		Namep eqvname;
49843206Sbostic 		} eqvitem;
49943206Sbostic 	long int eqvoffset;
50043206Sbostic 	} ;
50143206Sbostic 
50243206Sbostic 
50343206Sbostic union Taggedblock
50443206Sbostic 	{
50543206Sbostic 	field tag;
50643206Sbostic 	struct Headblock headblock;
50743206Sbostic 	struct Nameblock nameblock;
50843206Sbostic 	struct Paramblock paramblock;
50943206Sbostic 	struct Exprblock exprblock;
51043206Sbostic 	struct Constblock constblock;
51143206Sbostic 	struct Listblock listblock;
51243206Sbostic 	struct Addrblock addrblock;
51343206Sbostic 	struct Tempblock tempblock;
51443206Sbostic 	struct Errorblock errorblock;
51543206Sbostic 	struct Primblock primblock;
51643206Sbostic 	struct Impldoblock impldoblock;
51743206Sbostic 	} ;
51843206Sbostic 
51943206Sbostic 
52043206Sbostic 
52143206Sbostic 
52243206Sbostic struct Literal
52343206Sbostic 	{
52443206Sbostic 	short littype;
52543206Sbostic 	short litnum;
52643206Sbostic 	union	{
52743206Sbostic 		ftnint litival;
52843206Sbostic 		double litdval;
52943206Sbostic 		struct	{
53043206Sbostic 			char litclen;	/* small integer */
53143206Sbostic 			char litcstr[XL];
53243206Sbostic 			} litcval;
53343206Sbostic 		} litval;
53443206Sbostic 	};
53543206Sbostic 
53643206Sbostic extern struct Literal litpool[ ];
53743206Sbostic extern int nliterals;
53843206Sbostic 
53943206Sbostic 
54043206Sbostic 
54143206Sbostic /* popular functions with non integer return values */
54243206Sbostic 
54343206Sbostic 
54443206Sbostic int *ckalloc();
54543206Sbostic char *varstr(), *nounder(), *varunder();
54643206Sbostic char *copyn(), *copys();
54743206Sbostic chainp hookup(), mkchain();
54843206Sbostic ftnint convci();
54943206Sbostic char *convic();
55043206Sbostic char *setdoto();
55143206Sbostic double convcd();
55243206Sbostic Namep mkname();
55343206Sbostic struct Labelblock *mklabel(), *execlab();
55443206Sbostic struct Extsym *mkext(), *newentry();
55543206Sbostic expptr addrof(), call1(), call2(), call3(), call4();
55643206Sbostic Tempp mktmpn();
55743206Sbostic Addrp builtin(), mktemp(), altmpn(), mkaltemp(), mkaltmpn(), autovar();
55843206Sbostic Addrp mkplace(), mkaddr(), putconst(), memversion();
55943206Sbostic expptr mkprim(), mklhs(), mkexpr(), mkconv(), mkfunct(), fixexpr(), fixtype();
56043206Sbostic expptr errnode(), mkintcon();
56143206Sbostic tagptr cpexpr();
56243206Sbostic ftnint lmin(), lmax(), iarrlen();
563