xref: /csrg-svn/old/pcc/mip/manifest (revision 17745)
1*17745Sralph/*	manifest	4.3	85/01/18	*/
217451Sralph
317451Sralph# include <stdio.h>
4*17745Sralph
517451Sralph/*	manifest constant file for the lex/yacc interface */
617451Sralph
717451Sralph# define ERROR 1
817451Sralph# define NAME 2
917451Sralph# define STRING 3
1017451Sralph# define ICON 4
1117451Sralph# define FCON 5
12*17745Sralph# define DCON 6
13*17745Sralph# define PLUS 9
14*17745Sralph# define MINUS 11
15*17745Sralph# define MUL 14
16*17745Sralph# define AND 17
17*17745Sralph# define OR 20
18*17745Sralph# define ER 22
19*17745Sralph# define QUEST 24
20*17745Sralph# define COLON 25
21*17745Sralph# define ANDAND 26
22*17745Sralph# define OROR 27
2317451Sralph
2417451Sralph/* the defines for ASOP, RELOP, EQUOP, DIVOP,
2517451Sralph   SHIFTOP, ICOP, UNOP, and STROP have been
2617451Sralph   moved to mfile1				*/
2717451Sralph/*	reserved words, etc */
28*17745Sralph# define TYPE 36
29*17745Sralph# define CLASS 37
30*17745Sralph# define STRUCT 38
31*17745Sralph# define RETURN 39
32*17745Sralph# define GOTO 40
33*17745Sralph# define IF 41
34*17745Sralph# define ELSE 42
35*17745Sralph# define SWITCH 43
36*17745Sralph# define BREAK 44
37*17745Sralph# define CONTINUE 45
38*17745Sralph# define WHILE 46
39*17745Sralph# define DO 47
40*17745Sralph# define FOR 48
41*17745Sralph# define DEFAULT 49
42*17745Sralph# define CASE 50
43*17745Sralph# define SIZEOF 51
44*17745Sralph# define ENUM 52
4517451Sralph
4617451Sralph/*	little symbols, etc. */
4717451Sralph/*	namely,
4817451Sralph
4917451Sralph	LP	(
5017451Sralph	RP	)
5117451Sralph
5217451Sralph	LC	{
5317451Sralph	RC	}
5417451Sralph
5517451Sralph	LB	[
5617451Sralph	RB	]
5717451Sralph
5817451Sralph	CM	,
5917451Sralph	SM	;
6017451Sralph
6117451Sralph	*/
6217451Sralph
6317451Sralph/*  These defines are being moved to mfile1
6417451Sralph    to alleviate preprocessor problems with
65*17745Sralph    second pass files: LP, RP, LC, RC */
66*17745Sralph# define LB 57
67*17745Sralph# define RB 58
68*17745Sralph# define CM 59
69*17745Sralph# define SM 60
70*17745Sralph# define ASSIGN 61
7117451Sralph
7217451Sralph/*	END OF YACC */
7317451Sralph
7417451Sralph/*	left over tree building operators */
75*17745Sralph#define COMOP	62		/* , operator */
76*17745Sralph#define DIV	63		/* / */
77*17745Sralph#define MOD	65		/* % */
78*17745Sralph#define LS	67		/* << */
79*17745Sralph#define RS	69		/* >> */
80*17745Sralph#define DOT	71		/* . */
81*17745Sralph#define STREF	72		/* -> */
82*17745Sralph#define CALL	73		/* C function call */
83*17745Sralph#define FORTCALL 76		/* Fortran function call */
84*17745Sralph#define NOT	79		/* ! */
85*17745Sralph#define COMPL	80		/* ~ */
86*17745Sralph#define INCR	81		/* ++ */
87*17745Sralph#define DECR	82		/* -- */
88*17745Sralph#define EQ	83		/* == */
89*17745Sralph#define NE	84		/* != */
90*17745Sralph#define LE	85		/* <= */
91*17745Sralph#define LT	86		/* < */
92*17745Sralph#define GE	87		/* >= */
93*17745Sralph#define GT	88		/* > */
94*17745Sralph#define ULE	89		/* unsigned <= */
95*17745Sralph#define ULT	90		/* unsigned < */
96*17745Sralph#define UGE	91		/* unsigned >= */
97*17745Sralph#define UGT	92		/* unsigned > */
98*17745Sralph#define	SETBIT	93		/* unused */
99*17745Sralph#define TESTBIT	94		/* unused */
100*17745Sralph#define RESETBIT 95		/* unused */
101*17745Sralph#define ARS	96		/* arithmetic >> */
102*17745Sralph#define REG	97		/* register */
103*17745Sralph#define OREG	98		/* offset from register */
104*17745Sralph#define CCODES	99		/* condition codes */
105*17745Sralph#define FREE	100		/* free node */
106*17745Sralph#define STASG	101		/* structure assignment */
107*17745Sralph#define STARG	102		/* structure parameter */
108*17745Sralph#define STCALL	103		/* call to function returning structure */
10917451Sralph
110*17745Sralph/* some conversion operators */
111*17745Sralph#define FLD	106		/* field */
112*17745Sralph#define SCONV	107		/* storage conversion */
113*17745Sralph#define PCONV	108		/* pointer conversion */
114*17745Sralph#define PMCONV	109		/* pointer multiply conversion (from +) */
115*17745Sralph#define PVCONV	110		/* pointer divide conversion (from -) */
11617451Sralph
117*17745Sralph/* special node operators, used for special contexts */
118*17745Sralph#define FORCE	111		/* force result, for return values */
119*17745Sralph#define CBRANCH	112		/* condition branch */
120*17745Sralph#define INIT	113		/* data initialization */
121*17745Sralph#define CAST	114		/* type cast */
12217451Sralph
12317451Sralph/*	node types */
12417451Sralph# define LTYPE 02
12517451Sralph# define UTYPE 04
12617451Sralph# define BITYPE 010
12717451Sralph
12817451Sralph	/* DSIZE is the size of the dope array */
12917451Sralph# define DSIZE CAST+1
13017451Sralph
13117451Sralph/*	type names, used in symbol table building */
13217451Sralph# define TNULL PTR    /* pointer to UNDEF */
13317451Sralph# define TVOID FTN	/* function returning UNDEF (for void) */
13417451Sralph# define UNDEF 0
13517451Sralph# define FARG 1
13617451Sralph# define CHAR 2
13717451Sralph# define SHORT 3
13817451Sralph# define INT 4
13917451Sralph# define LONG 5
14017451Sralph# define FLOAT 6
14117451Sralph# define DOUBLE 7
14217451Sralph# define STRTY 8
14317451Sralph# define UNIONTY 9
14417451Sralph# define ENUMTY 10
14517451Sralph# define MOETY 11
14617451Sralph# define UCHAR 12
14717451Sralph# define USHORT 13
14817451Sralph# define UNSIGNED 14
14917451Sralph# define ULONG 15
15017451Sralph
15117451Sralph# define ASG 1+
15217451Sralph# define UNARY 2+
15317451Sralph# define NOASG (-1)+
15417451Sralph# define NOUNARY (-2)+
15517451Sralph
15617451Sralph/*	various flags */
15717451Sralph# define NOLAB (-1)
15817451Sralph
15917451Sralph/* type modifiers */
16017451Sralph
16117451Sralph# define PTR  020
16217451Sralph# define FTN  040
16317451Sralph# define ARY  060
16417451Sralph
16517451Sralph/* type packing constants */
16617451Sralph
16717451Sralph# define TMASK 060
16817451Sralph# define TMASK1 0300
16917451Sralph# define TMASK2  0360
17017451Sralph# define BTMASK 017
17117451Sralph# define BTSHIFT 4
17217451Sralph# define TSHIFT 2
17317451Sralph
17417451Sralph/*	macros	*/
17517451Sralph
17617451Sralph# define MODTYPE(x,y) x = ( (x)&(~BTMASK))|(y)  /* set basic type of x to y */
17717451Sralph# define BTYPE(x)  ( (x)&BTMASK)   /* basic type of x */
17817451Sralph# define ISUNSIGNED(x) ((x)<=ULONG&&(x)>=UCHAR)
17917451Sralph# define UNSIGNABLE(x) ((x)<=LONG&&(x)>=CHAR)
18017451Sralph# define ENUNSIGN(x) ((x)+(UNSIGNED-INT))
18117451Sralph# define DEUNSIGN(x) ((x)+(INT-UNSIGNED))
18217451Sralph# define ISPTR(x) (( (x)&TMASK)==PTR)
18317451Sralph# define ISFTN(x)  (( (x)&TMASK)==FTN)  /* is x a function type */
18417451Sralph# define ISARY(x)   (( (x)&TMASK)==ARY)   /* is x an array type */
18517451Sralph# define INCREF(x) ((( (x)&~BTMASK)<<TSHIFT)|PTR|( (x)&BTMASK))
18617451Sralph# define DECREF(x) ((( (x)>>TSHIFT)&~BTMASK)|( (x)&BTMASK))
18717451Sralph# define SETOFF(x,y)   if( (x)%(y) != 0 ) (x) = ( ((x)/(y) + 1) * (y))
18817451Sralph		/* advance x to a multiple of y */
18917451Sralph# define NOFIT(x,y,z)   ( ( (x)%(z) + (y) ) > (z) )
19017451Sralph		/* can y bits be added to x without overflowing z */
19117451Sralph	/* pack and unpack field descriptors (size and offset) */
19217451Sralph# define PKFIELD(s,o) (( (o)<<6)| (s) )
19317451Sralph# define UPKFSZ(v)  ( (v) &077)
19417451Sralph# define UPKFOFF(v) ( (v) >>6)
19517451Sralph
19617451Sralph/*	operator information */
19717451Sralph
19817451Sralph# define TYFLG 016
19917451Sralph# define ASGFLG 01
20017451Sralph# define LOGFLG 020
20117451Sralph
20217451Sralph# define SIMPFLG 040
20317451Sralph# define COMMFLG 0100
20417451Sralph# define DIVFLG 0200
20517451Sralph# define FLOFLG 0400
20617451Sralph# define LTYFLG 01000
20717451Sralph# define CALLFLG 02000
20817451Sralph# define MULFLG 04000
20917451Sralph# define SHFFLG 010000
21017451Sralph# define ASGOPFLG 020000
21117451Sralph
21217451Sralph# define SPFLG 040000
21317451Sralph
21417451Sralph#define optype(o) (dope[o]&TYFLG)
21517451Sralph#define asgop(o) (dope[o]&ASGFLG)
21617451Sralph#define logop(o) (dope[o]&LOGFLG)
21717451Sralph#define callop(o) (dope[o]&CALLFLG)
21817451Sralph
21917451Sralph/*	table sizes	*/
22017451Sralph
22117451Sralph# define TREESZ 1000
22217451Sralph
22317451Sralph#ifndef FLEXNAMES
22417451Sralph# define NCHNAM 8  /* number of characters in a name */
22517451Sralph#else
22617451Sralphchar *hash();
22717451Sralphchar *savestr();
22817451Sralphchar *tstr();
22917451Sralphextern int tstrused;
23017451Sralphextern char *tstrbuf[], **curtstr;
23117451Sralph#define	freetstr()	curtstr = tstrbuf, tstrused = 0
23217451Sralph#endif
23317451Sralph
23417451Sralph/*	common defined variables */
23517451Sralph
23617451Sralphextern int nerrors;  /* number of errors seen so far */
23717451Sralph
23817451Sralphtypedef union ndu NODE;
23917451Sralphtypedef unsigned int TWORD;
24017451Sralph# define NIL (NODE *)0
24117451Sralphextern int dope[];  /* a vector containing operator information */
24217451Sralphextern char *opst[];  /* a vector containing names for ops */
24317451Sralph
24417451Sralph# ifdef ONEPASS
24517451Sralph	/* in one-pass operation, define the tree nodes */
24617451Sralph
24717451Sralphunion ndu {
24817451Sralph
24917451Sralph	struct {
25017451Sralph		int op;
25117451Sralph		int rall;
25217451Sralph		TWORD type;
25317451Sralph		int su;
25417451Sralph#ifndef FLEXNAMES
25517451Sralph		char name[NCHNAM];
25617451Sralph#else
25717451Sralph		char *name;
25817451Sralph		int stalign;
25917451Sralph#endif
26017451Sralph		NODE *left;
26117451Sralph		NODE *right;
26217451Sralph		}in; /* interior node */
26317451Sralph
26417451Sralph	struct {
26517451Sralph		int op;
26617451Sralph		int rall;
26717451Sralph		TWORD type;
26817451Sralph		int su;
26917451Sralph#ifndef FLEXNAMES
27017451Sralph		char name[NCHNAM];
27117451Sralph#else
27217451Sralph		char *name;
27317451Sralph		int stalign;
27417451Sralph#endif
27517451Sralph		CONSZ lval;
27617451Sralph		int rval;
27717451Sralph		}tn; /* terminal node */
27817451Sralph
27917451Sralph	struct {
28017451Sralph		int op, rall;
28117451Sralph		TWORD type;
28217451Sralph		int su;
28317451Sralph		int label;  /* for use with branching */
28417451Sralph		}bn; /* branch node */
28517451Sralph
28617451Sralph	struct {
28717451Sralph		int op, rall;
28817451Sralph		TWORD type;
28917451Sralph		int su;
29017451Sralph		int stsize;  /* sizes of structure objects */
29117451Sralph		int stalign;  /* alignment of structure objects */
29217451Sralph		}stn; /* structure node */
29317451Sralph
29417451Sralph	struct {
29517451Sralph		int op;
29617451Sralph		int cdim;
29717451Sralph		TWORD type;
29817451Sralph		int csiz;
29917451Sralph		}fn; /* front node */
30017451Sralph
30117451Sralph	struct {
302*17745Sralph		/* this structure is used when a single precision constant
30317451Sralph		   is being computed */
30417451Sralph		int op;
30517451Sralph		int cdim;
30617451Sralph		TWORD type;
30717451Sralph		int csiz;
308*17745Sralph		float fval;
309*17745Sralph		}fpn; /* FCON node */
310*17745Sralph
311*17745Sralph	struct {
312*17745Sralph		/* this structure is used when a double precision constant
313*17745Sralph		   is being computed */
314*17745Sralph		int op;
315*17745Sralph		int cdim;
316*17745Sralph		TWORD type;
317*17745Sralph		int csiz;
31817451Sralph		double dval;
319*17745Sralph		}dpn; /* DCON node */
32017451Sralph
32117451Sralph	};
32217451Sralph# endif
32317451Sralph# ifdef BUG2
32417451Sralph# define BUG1
32517451Sralph# endif
32617451Sralph# ifdef BUG3
32717451Sralph# define BUG2
32817451Sralph# define BUG1
32917451Sralph# endif
33017451Sralph# ifdef BUG4
33117451Sralph# define BUG1
33217451Sralph# define BUG2
33317451Sralph# define BUG3
33417451Sralph# endif
33517451Sralph# ifndef ONEPASS
33617451Sralph
33717451Sralph# ifndef EXPR
33817451Sralph# define EXPR '.'
33917451Sralph# endif
34017451Sralph# ifndef BBEG
34117451Sralph# define BBEG '['
34217451Sralph# endif
34317451Sralph# ifndef BEND
34417451Sralph# define BEND ']'
34517451Sralph# endif
34617451Sralph
34717451Sralph# endif
348