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