# include "macdefs"
# include "mac2defs"
# include "manifest"
# ifdef ONEPASS
/*
 *	bunch of stuff for putting the passes together...
 */
# define crslab crs2lab
# define where where2
# define xdebug x2debug
# define tdebug t2debug
# define deflab def2lab
# define edebug e2debug
# define eprint e2print
# define getlab get2lab
# define filename ftitle
# endif
/*
 *	cookies, used as arguments to codgen
 */
#if slash6
# define FOREFF		01	/* compute for effects only */
# define INAREG		02	/* compute into arithmetic register */
# define ININREG	04	/* compute into index register */
# define INBREG	       010	/* compute into byte register */
# define INACREG       020	/* compute into accumulator */
# define INDREG	       040	/* compute into double register */
# define INXREG	      0100	/* compute into floating accumulator */
# define INIREG	      0200	/* compute into i register */
# define INJREG	      0400	/* compute into j register */
# define FORCC	     01000	/* compute for condition codes only */
# define INTEMP	   0400000	/* compute into a temporary location */
# define FORARG	  01000000	/* compute for an argument of a function */
# define FORREW	  02000000	/* search the table, looking for a rewrite rule */
#else
# define FOREFF		01L	/* compute for effects only */
# define INAREG		02L	/* compute into arithmetic register */
# define ININREG	04L	/* compute into index register */
# define INBREG	       010L	/* compute into byte register */
# define INACREG       020L	/* compute into accumulator */
# define INDREG	       040L	/* compute into double register */
# define INXREG	      0100L	/* compute into floating accumulator */
# define INIREG	      0200L	/* compute into i register */
# define INJREG	      0400L	/* compute into j register */
# define FORCC	     01000L	/* compute for condition codes only */
# define INTEMP	   0400000L	/* compute into a temporary location */
# define FORARG	  01000000L	/* compute for an argument of a function */
# define FORREW	  02000000L	/* search the table, looking for a rewrite rule */
#endif
/*
 * OP descriptors
 * the ASG operator may be used on some of these
 */
# define OPSIMP		010000	/* +, -, &, |, ^ */
# define OPCOMM		010002	/* +, &, |, ^ */
# define OPMUL		010004	/* *, / */
# define OPDIV		010006	/* /, % */
# define OPUNARY	010010	/* unary ops */
# define OPLEAF		010012	/* leaves */
# define OPANY		010014	/* any op... */
# define OPLOG		010016	/* logical ops */
# define OPFLOAT	010020	/* +, -, *, or / (for floats) */
# define OPSHFT		010022	/* <<, >> */
# define OPLTYPE	010024	/* leaf type nodes (e.g, NAME, ICON, etc. ) */
/*
 * match returns
 */
# define MNOPE	010000
# define MDONE	010001
/*
 * shapes
 *
 * FORARG and INTEMP are carefully not conflicting with shapes
 */
#if slash6
# define SANY		01	/* same as FOREFF */
# define SAREG		02	/* same as INAREG */
# define SINREG		04	/* same as ININREG */
# define SBREG	       010	/* same as INBREG */
# define SACREG	       020	/* same as INACREG */
# define SDREG	       040	/* same as INDREG */
# define SXREG	      0100	/* same as INXREG */
# define SIREG	      0200	/* same as INIREG */
# define SJREG	      0400	/* same as INJREG */
# define SCC	     01000	/* same as FORCC */
# define SNAME	     02000
# define SCON	     04000
# define SFLD	    010000
# define SOREG	    020000
# define STARNM	    040000
# define STJREG    0100000
# define SWADD	   0200000
# define SPECIAL  04000000
# define SZERO	    SPECIAL
# define SONE	(SPECIAL|1)
# define SMONE	(SPECIAL|2)
# define SKREG	 010000000
# define STIREG  020000000
#else
# define SANY		01L	/* same as FOREFF */
# define SAREG		02L	/* same as INAREG */
# define SINREG		04L	/* same as ININREG */
# define SBREG	       010L	/* same as INBREG */
# define SACREG	       020L	/* same as INACREG */
# define SDREG	       040L	/* same as INDREG */
# define SXREG	      0100L	/* same as INXREG */
# define SIREG	      0200L	/* same as INIREG */
# define SJREG	      0400L	/* same as INJREG */
# define SCC	     01000L	/* same as FORCC */
# define SNAME	     02000L
# define SCON	     04000L
# define SFLD	    010000L
# define SOREG	    020000L
# define STARNM	    040000L
# define STJREG    0100000L
# define SWADD	   0200000L
# define SPECIAL  04000000L
# define SZERO	    SPECIAL
# define SONE	(SPECIAL|1)
# define SMONE	(SPECIAL|2)
# define SKREG	 010000000L
# define STIREG  020000000L
#endif
/*
 * types
 *
 * Note distinction between byte pointers and any other type of pointer
 */
# define TCHAR		    01
# define TSHORT		    02
# define TINT		    04
# define TLONG		   010
# define TFLOAT		   020
# define TDOUBLE	   040
# define TPOINT		  0100			/* pointer to anything but char */
# define TUCHAR		  0200
# define TUSHORT	  0400
# define TUNSIGNED	 01000
# define TULONG		 02000
# define TPTRTO		 04000			/* pointer to one of the above */
# define TANY		010000			/* matches anything within reason */
# define TSTRUCT	020000			/* structure or union */
/*
 * reclamation cookies
 */
# define RNULL		0			 /* clobber result */
# define RLEFT		01
# define RRIGHT		02
# define RESC1		04
# define RESC2		010
# define RESC3		020
# define RESCC		04000
# define RNOP		010000			/* DANGER: can cause loops.. */
/*
 *	Needs, as found in the code tables,
 */
# define NAREG		01
# define NACOUNT	03
# define NASR		04
# define NASL		010
# define NAMASK		017
# define NINREG		020
# define NINCOUNT	060
# define NINMASK	060
# define NBREG		0100
# define NBMASK		0100
# define NACREG		0200
# define NDREG		0400
# define NIREG		01000
# define NJREG		02000
# define NXREG		04000
# define NTEMP		010000
# define NTMASK		030000
# define REWRITE	040000
# define MUSTDO		010000	/* force register requirements */
# define NOPREF		020000	/* no preference as to register */
/*
 * register allocation
 */
extern SHAPESZ	rstatus[];
extern int	busy[],
		*regoverlap[];			 /* physical overlap table */
extern struct respref {
	COOKSZ	cform;			/* form of cookie */
	COOKSZ	mform;			/* match return */
}respref[];
# define istnode(p) (p->op==REG && istreg(p->rval))
# define TBUSY 01000
# define REGLOOP(i) for(i=0;i<REGSZ;++i)
/*
 *	For now everything is a temporary except the k register
 */
# define istreg(r)	(r != Rk)
# define SETSTO(x,y) (stotree=(x),stocook=(y))
# define DELAYS 20
extern COOKSZ	stocook;
extern int      deli;				 /* mmmmm */
extern NODE	*deltrees[DELAYS];
extern NODE	*stotree;
extern int      callflag;
extern int      fregs;
# ifndef ONEPASS
union ndu {
	struct {
		int     op;
		int     rall;
	        TWORD	type;
		int     su;
		char    name[NCHNAM+1];
		NODE	*left,
			*right;
	};
	struct {
		int     op;
		int     rall;
		TWORD	type;
		int     su;
		char    name[NCHNAM+1];
		CONSZ	lval;
		int     rval;
	};
	struct {
		int     op,
		        rall;
		TWORD	type;
		int     su;
		int     label;			 /* for use with branching */
	};
	struct {
		int     op,
		        rall;
		TWORD	type;
		int     su;
		int     stsize;			 /* sizes of structure objects */
		int     stalign;		 /* alignment of structure objects */
	};
};
#endif
#if vulcan
NODE	node[TREESZ];
#else
extern  NODE node[];
#endif
extern struct optab {
	int     op;			/* operator, or group of */
	COOKSZ	visit;			/* cookie(s) to match */
	SHAPESZ	lshape;			/* left tree shape */
	int     ltype;			/* left tree type */
	SHAPESZ	rshape;			/* right tree shape */
	int     rtype;			/* right tree type */
	NEEDSZ	needs;			/* resource needs */
	int     rewrite;		/* rewrite operator */
	char   *cstring;		/* code to be expanded */
}table[];
#if vulcan
NODE	resc[3];
#else
extern  NODE resc[];
#endif
extern OFFSZ	tmpoff;
extern OFFSZ	maxoff;
extern OFFSZ	baseoff;
extern OFFSZ	maxtemp;
extern int      maxtreg;
extern int      ftnno;
extern int      rtyflg;
extern int      nrecur;				 /* flag to keep track of recursions */
# define NRECUR (10*TREESZ)
extern NODE	*talloc(),
		*eread (),
		*tcopy (),
		*getlr ();
extern CONSZ	rdin ();
extern int      eprint ();
extern SHAPESZ	shumul();
extern char    *rnames[];
extern int      lineno;
extern char     filename[];
extern int      fldshf,
                fldsz;
extern int      lflag,
                xdebug,
                udebug,
                edebug,
                odebug,
                rdebug,
                radebug,
                tdebug,
                sdebug;
#ifndef callchk
#define callchk(x) allchk()
#endif
#ifndef PUTCHAR
# define PUTCHAR(x) putchar(x)
#endif
#if R2REGS
/*
 * macros for doing double indexing
 */
# define R2PACK(x,y) (0200*((x)+1)+y)
# define R2UPK1(x) (((x)>>7)-1)
# define R2UPK2(x) ((x)&0177)
# define R2TEST(x) ((x)>=0200)
#endif
