1*17746Sralph/* @(#)mfile1 4.3 (Berkeley) 85/01/18 */ 211835Smckusick 311835Smckusick# include "macdefs" 411835Smckusick# include "manifest" 511835Smckusick 611835Smckusick/* storage classes */ 711835Smckusick# define SNULL 0 811835Smckusick# define AUTO 1 911835Smckusick# define EXTERN 2 1011835Smckusick# define STATIC 3 1111835Smckusick# define REGISTER 4 1211835Smckusick# define EXTDEF 5 1311835Smckusick# define LABEL 6 1411835Smckusick# define ULABEL 7 1511835Smckusick# define MOS 8 1611835Smckusick# define PARAM 9 1711835Smckusick# define STNAME 10 1811835Smckusick# define MOU 11 1911835Smckusick# define UNAME 12 2011835Smckusick# define TYPEDEF 13 2111835Smckusick# define FORTRAN 14 2211835Smckusick# define ENAME 15 2311835Smckusick# define MOE 16 2411835Smckusick# define UFORTRAN 17 2511835Smckusick# define USTATIC 18 2611835Smckusick /* field size is ORed in */ 2711835Smckusick# define FIELD 0100 2811835Smckusick# define FLDSIZ 077 2911835Smckusick# ifndef BUG1 3011835Smckusickextern char *scnames(); 3111835Smckusick# endif 3211835Smckusick 3311835Smckusick/* location counters */ 3411835Smckusick# define PROG 0 3511835Smckusick# define DATA 1 3611835Smckusick# define ADATA 2 3711835Smckusick# define STRNG 3 3811835Smckusick# define ISTRNG 4 3911835Smckusick# define STAB 5 4011835Smckusick 4111835Smckusick 4211835Smckusick/* symbol table flags */ 4311835Smckusick# define SMOS 01 4411835Smckusick# define SHIDDEN 02 4511835Smckusick# define SHIDES 04 4611835Smckusick# define SSET 010 4711835Smckusick# define SREF 020 4811835Smckusick# define SNONUNIQ 040 4911835Smckusick# define STAG 0100 5011835Smckusick 5111835Smckusick# ifndef FIXDEF 5211835Smckusick# define FIXDEF(p) 5311835Smckusick#endif 5411835Smckusick# ifndef FIXARG 5511835Smckusick# define FIXARG(p) 5611835Smckusick# endif 5711835Smckusick# ifndef FIXSTRUCT 5811835Smckusick# define FIXSTRUCT(a,b) 5911835Smckusick# endif 6011835Smckusick 6111835Smckusick /* alignment of initialized quantities */ 6211835Smckusick# ifndef AL_INIT 6311835Smckusick# define AL_INIT ALINT 6411835Smckusick# endif 6511835Smckusick 6611835Smckusickstruct symtab { 6711835Smckusick#ifndef FLEXNAMES 6811835Smckusick char sname[NCHNAM]; 6911835Smckusick#else 7011835Smckusick char *sname; 7111835Smckusick#endif 7211835Smckusick TWORD stype; /* type word */ 7311835Smckusick 7411835Smckusick char sclass; /* storage class */ 7511835Smckusick char slevel; /* scope level */ 7611835Smckusick char sflags; /* flags for set, use, hidden, mos, etc. */ 7711835Smckusick int offset; /* offset or value */ 7811835Smckusick short dimoff; /* offset into the dimension table */ 7911835Smckusick short sizoff; /* offset into the size table */ 8011835Smckusick short suse; /* line number of last use of the variable */ 8111835Smckusick }; 8211835Smckusick 8311835Smckusick 8411835Smckusick# ifdef ONEPASS 8511835Smckusick/* NOPREF must be defined for use in first pass tree machine */ 8611835Smckusick# define NOPREF 020000 /* no preference for register assignment */ 8711835Smckusick#else 8811835Smckusick 8911835Smckusickunion ndu { 9011835Smckusick struct { 9111835Smckusick int op; 9211835Smckusick TWORD type; 9311835Smckusick int cdim, csiz; 9411835Smckusick }fn; /* front node */ 9511835Smckusick struct { 9611835Smckusick int op; 9711835Smckusick TWORD type; 9811835Smckusick int cdim, csiz; 9911835Smckusick NODE *left; 10011835Smckusick NODE * right; 10111835Smckusick }in; /* interior node */ 10211835Smckusick 10311835Smckusick struct { 10411835Smckusick /* this structure is the same as above, 10511835Smckusick but is used when a value, rather than 10611835Smckusick address, is kept in +left */ 10711835Smckusick int op; 10811835Smckusick TWORD type; 10911835Smckusick int cdim, csiz; 11011835Smckusick CONSZ lval; 11111835Smckusick int rval; 11211835Smckusick }tn; /* terminal node */ 113*17746Sralph 11411835Smckusick struct { 115*17746Sralph /* this structure is used when a single precision constant 11611835Smckusick is being computed */ 11711835Smckusick int op; 11811835Smckusick TWORD type; 11911835Smckusick int cdim, csiz; 120*17746Sralph float fval; 121*17746Sralph }fpn; /* FCON node */ 122*17746Sralph 123*17746Sralph struct { 124*17746Sralph /* this structure is used when a double precision constant 125*17746Sralph is being computed */ 126*17746Sralph int op; 127*17746Sralph TWORD type; 128*17746Sralph int cdim, csiz; 12911835Smckusick double dval; 130*17746Sralph }dpn; /* DCON node */ 13111835Smckusick 13211835Smckusick }; 13311835Smckusick# endif 13411835Smckusick 13511835Smckusickstruct sw { 13611835Smckusick CONSZ sval; 13711835Smckusick int slab; 13811835Smckusick }; 13911835Smckusick 14011835Smckusickextern struct sw swtab[]; 14111835Smckusickextern struct sw *swp; 14211835Smckusickextern int swx; 14311835Smckusick 14411835Smckusickextern int ftnno; 14511835Smckusickextern int blevel; 14611835Smckusickextern int instruct, stwart; 14711835Smckusick 14811835Smckusickextern int lineno, nerrors; 14911835Smckusicktypedef union { 15011835Smckusick int intval; 15111835Smckusick NODE * nodep; 15211835Smckusick } YYSTYPE; 15311835Smckusickextern YYSTYPE yylval; 15411835Smckusick 15511835Smckusickextern CONSZ lastcon; 156*17746Sralphextern float fcon; 15711835Smckusickextern double dcon; 15811835Smckusick 15911835Smckusickextern char ftitle[]; 16011835Smckusickextern char ititle[]; 16111835Smckusickextern struct symtab stab[]; 16211835Smckusickextern int curftn; 16311835Smckusickextern int curclass; 16411835Smckusickextern int curdim; 16511835Smckusickextern int dimtab[]; 16611835Smckusickextern int paramstk[]; 16711835Smckusickextern int paramno; 16811835Smckusickextern int autooff, argoff, strucoff; 16911835Smckusickextern int regvar; 17011835Smckusickextern int minrvar; 17111835Smckusickextern int brkflag; 17211835Smckusickextern char yytext[]; 17311835Smckusick 17411835Smckusickextern int strflg; 17511835Smckusick 17611835Smckusickextern OFFSZ inoff; 17711835Smckusick 17811835Smckusickextern int reached; 17911835Smckusick 18011835Smckusick/* tunnel to buildtree for name id's */ 18111835Smckusick 18211835Smckusickextern int idname; 18311835Smckusick 18411835Smckusickextern NODE node[]; 18511835Smckusickextern NODE *lastfree; 18611835Smckusick 18711835Smckusickextern int cflag, hflag, pflag; 18811835Smckusick 18911835Smckusick/* various labels */ 19011835Smckusickextern int brklab; 19111835Smckusickextern int contlab; 19211835Smckusickextern int flostat; 19311835Smckusickextern int retlab; 19411835Smckusickextern int retstat; 19511835Smckusickextern int asavbc[], *psavbc; 19611835Smckusick 19711835Smckusick/* flags used in structures/unions */ 19811835Smckusick 19911835Smckusick# define SEENAME 01 20011835Smckusick# define INSTRUCT 02 20111835Smckusick# define INUNION 04 20211835Smckusick# define FUNNYNAME 010 20311835Smckusick# define TAGNAME 020 20411835Smckusick 20511835Smckusick/* flags used in the (elementary) flow analysis ... */ 20611835Smckusick 20711835Smckusick# define FBRK 02 20811835Smckusick# define FCONT 04 20911835Smckusick# define FDEF 010 21011835Smckusick# define FLOOP 020 21111835Smckusick 21211835Smckusick/* flags used for return status */ 21311835Smckusick 21411835Smckusick# define RETVAL 1 21511835Smckusick# define NRETVAL 2 21611835Smckusick 21711835Smckusick/* used to mark a constant with no name field */ 21811835Smckusick 21911835Smckusick# define NONAME 040000 22011835Smckusick 22111835Smckusick /* mark an offset which is undefined */ 22211835Smckusick 22311835Smckusick# define NOOFFSET (-10201) 22411835Smckusick 22511835Smckusick/* declarations of various functions */ 22611835Smckusick 22711835Smckusickextern NODE 22811835Smckusick *buildtree(), 22911835Smckusick *bdty(), 23011835Smckusick *mkty(), 23111835Smckusick *rstruct(), 23211835Smckusick *dclstruct(), 23311835Smckusick *getstr(), 23411835Smckusick *tymerge(), 23511835Smckusick *stref(), 23611835Smckusick *offcon(), 23711835Smckusick *bcon(), 23811835Smckusick *bpsize(), 23911835Smckusick *convert(), 24011835Smckusick *pconvert(), 24111835Smckusick *oconvert(), 24211835Smckusick *ptmatch(), 24311835Smckusick *tymatch(), 24411835Smckusick *makety(), 24511835Smckusick *block(), 24611835Smckusick *doszof(), 24711835Smckusick *talloc(), 24811835Smckusick *optim(), 249*17746Sralph *fixargs(), 25011835Smckusick *clocal(); 25111835Smckusick 25211835SmckusickOFFSZ tsize(), 25311835Smckusick psize(); 25411835Smckusick 25511835SmckusickTWORD types(); 25611835Smckusick 25711835Smckusick 25811835Smckusickdouble atof(); 25911835Smckusick 26011835Smckusickchar *exname(), *exdcon(); 26111835Smckusick 26211835Smckusick# define checkst(x) 26311835Smckusick 26411835Smckusick# ifndef CHARCAST 26511835Smckusick/* to make character constants into character connstants */ 26611835Smckusick/* this is a macro to defend against cross-compilers, etc. */ 26711835Smckusick# define CHARCAST(x) (char)(x) 26811835Smckusick# endif 26911835Smckusick 27011835Smckusick# define BCSZ 100 /* size of the table to save break and continue labels */ 27111836Smckusick# define SYMTSZ 3000 /* size of the symbol table (was 500) */ 27211836Smckusick# define DIMTABSZ 4200 /* size of the dimension/size table (was 800) */ 27311836Smckusick# define PARAMSZ 300 /* size of the parameter stack */ 27411835Smckusick# define SWITSZ 500 /* size of switch table */ 27511835Smckusick/* special interfaces for yacc alone */ 27611835Smckusick/* These serve as abbreviations of 2 or more ops: 27711835Smckusick ASOP =, = ops 27811835Smckusick RELOP LE,LT,GE,GT 27911835Smckusick EQUOP EQ,NE 28011835Smckusick DIVOP DIV,MOD 28111835Smckusick SHIFTOP LS,RS 28211835Smckusick ICOP ICR,DECR 28311835Smckusick UNOP NOT,COMPL 28411835Smckusick STROP DOT,STREF 28511835Smckusick 28611835Smckusick */ 287*17746Sralph# define ASOP 28 288*17746Sralph# define RELOP 29 289*17746Sralph# define EQUOP 30 290*17746Sralph# define DIVOP 31 291*17746Sralph# define SHIFTOP 32 292*17746Sralph# define INCOP 33 293*17746Sralph# define UNOP 34 294*17746Sralph# define STROP 35 29511835Smckusick 296*17746Sralph# define LP 53 297*17746Sralph# define RP 54 298*17746Sralph# define LC 55 299*17746Sralph# define RC 56 300