1# include "macdefs" 2# include "mac2defs" 3# include "manifest" 4 5# ifdef ONEPASS 6 7/* bunch of stuff for putting the passes together... */ 8# define crslab crs2lab 9# define where where2 10# define xdebug x2debug 11# define tdebug t2debug 12# define deflab def2lab 13# define edebug e2debug 14# define eprint e2print 15# define getlab get2lab 16# define filename ftitle 17# endif 18 19/* cookies, used as arguments to codgen */ 20 21# define FOREFF 01 /* compute for effects only */ 22# define INAREG 02 /* compute into a register */ 23# define INTAREG 04 /* compute into a scratch register */ 24# define INBREG 010 /* compute into a lvalue register */ 25# define INTBREG 020 /* compute into a scratch lvalue register */ 26# define FORCC 040 /* compute for condition codes only */ 27# define INTEMP 010000 /* compute into a temporary location */ 28# define FORARG 020000 /* compute for an argument of a function */ 29# define FORREW 040000 /* search the table, looking for a rewrite rule */ 30 31 /* OP descriptors */ 32 /* the ASG operator may be used on some of these */ 33 34# define OPSIMP 010000 /* +, -, &, |, ^ */ 35# define OPCOMM 010002 /* +, &, |, ^ */ 36# define OPMUL 010004 /* *, / */ 37# define OPDIV 010006 /* /, % */ 38# define OPUNARY 010010 /* unary ops */ 39# define OPLEAF 010012 /* leaves */ 40# define OPANY 010014 /* any op... */ 41# define OPLOG 010016 /* logical ops */ 42# define OPFLOAT 010020 /* +, -, *, or / (for floats) */ 43# define OPSHFT 010022 /* <<, >> */ 44# define OPLTYPE 010024 /* leaf type nodes (e.g, NAME, ICON, etc. ) */ 45 46 /* match returns */ 47 48# define MNOPE 010000 49# define MDONE 010001 50 51 /* shapes */ 52 53# define SANY 01 /* same as FOREFF */ 54# define SAREG 02 /* same as INAREG */ 55# define STAREG 04 /* same as INTAREG */ 56# define SBREG 010 /* same as INBREG */ 57# define STBREG 020 /* same as INTBREG */ 58# define SCC 040 /* same as FORCC */ 59# define SNAME 0100 60# define SCON 0200 61# define SFLD 0400 62# define SOREG 01000 63/* indirection or wild card shapes */ 64# ifndef WCARD1 65# define STARNM 02000 66# endif 67# ifndef WCARD2 68# define STARREG 04000 69# endif 70# define SWADD 040000 71# define SPECIAL 0100000 72# define SZERO SPECIAL 73# define SONE (SPECIAL|1) 74# define SMONE (SPECIAL|2) 75# define SCCON (SPECIAL|3) /* -256 <= constant < 256 */ 76# define SSCON (SPECIAL|4) /* -32768 <= constant < 32768 */ 77# define SSOREG (SPECIAL|5) /* non-indexed OREG */ 78 79 /* FORARG and INTEMP are carefully not conflicting with shapes */ 80 81 /* types */ 82 83# define TCHAR 01 84# define TSHORT 02 85# define TINT 04 86# define TLONG 010 87# define TFLOAT 020 88# define TDOUBLE 040 89# define TPOINT 0100 90# define TUCHAR 0200 91# define TUSHORT 0400 92# define TUNSIGNED 01000 93# define TULONG 02000 94# define TPTRTO 04000 /* pointer to one of the above */ 95# define TANY 010000 /* matches anything within reason */ 96# define TSTRUCT 020000 /* structure or union */ 97 98 /* reclamation cookies */ 99 100# define RNULL 0 /* clobber result */ 101# define RLEFT 01 102# define RRIGHT 02 103# define RESC1 04 104# define RESC2 010 105# define RESC3 020 106# define RESCC 04000 107# define RNOP 010000 /* DANGER: can cause loops.. */ 108 109 /* needs */ 110 111# define NAREG 01 112# define NACOUNT 03 113# define NAMASK 017 114# define NASL 04 /* share left register */ 115# define NASR 010 /* share right register */ 116# define NBREG 020 117# define NBCOUNT 060 118# define NBMASK 0360 119# define NBSL 0100 120# define NBSR 0200 121# define NTEMP 0400 122# define NTMASK 07400 123# define REWRITE 010000 124# define EITHER 040000 /* "either" modifier for needs */ 125 126 127# define MUSTDO 010000 /* force register requirements */ 128# define NOPREF 020000 /* no preference for register assignment */ 129 130 131 /* register allocation */ 132 133extern int rstatus[]; 134extern int busy[]; 135 136extern struct respref { int cform; int mform; } respref[]; 137 138# define isbreg(r) (rstatus[r]&SBREG) 139# define istreg(r) (rstatus[r]&(STBREG|STAREG)) 140# define istnode(p) (p->in.op==REG && istreg(p->tn.rval)) 141 142# define TBUSY 01000 143# define REGLOOP(i) for(i=0;i<REGSZ;++i) 144 145# define SETSTO(x,y) (stotree=(x),stocook=(y)) 146extern int stocook; 147# define DELAYS 20 148extern NODE *deltrees[DELAYS]; 149extern int deli; /* mmmmm */ 150 151extern NODE *stotree; 152extern int callflag; 153 154extern int fregs; 155 156# ifndef ONEPASS 157union ndu { 158 159 struct { 160 int op; 161 int rall; 162 TWORD type; 163 int su; 164#ifndef FLEXNAMES 165 char name[NCHNAM]; 166#else 167 char *name; 168#endif 169 int stalign; /* alignment of structure objects */ 170 NODE *left; 171 NODE *right; 172 }in; /* interior node */ 173 174 struct { 175 int op; 176 int rall; 177 TWORD type; 178 int su; 179#ifndef FLEXNAMES 180 char name[NCHNAM]; 181#else 182 char *name; 183#endif 184 int stalign; /* alignment of structure objects */ 185 CONSZ lval; 186 int rval; 187 }tn; /* terminal node */ 188 189 struct { 190 int op, rall; 191 TWORD type; 192 int su; 193 int label; /* for use with branching */ 194 }bn; /* branch node */ 195 196 struct { 197 int op, rall; 198 TWORD type; 199 int su; 200 int stsize; /* sizes of structure objects */ 201 int stalign; /* alignment of structure objects */ 202 }stn; /* structure node */ 203 204 }; 205#endif 206 207extern NODE node[]; 208 209extern struct optab { 210 int op; 211 int visit; 212 int lshape; 213 int ltype; 214 int rshape; 215 int rtype; 216 int needs; 217 int rewrite; 218 char * cstring; 219 } 220 table[]; 221 222extern NODE resc[]; 223 224extern OFFSZ tmpoff; 225extern OFFSZ maxoff; 226extern OFFSZ baseoff; 227extern OFFSZ maxtemp; 228extern int maxtreg; 229extern int ftnno; 230extern int rtyflg; 231 232extern int nrecur; /* flag to keep track of recursions */ 233 234# define NRECUR (10*TREESZ) 235 236extern NODE 237 *talloc(), 238 *eread(), 239 *tcopy(), 240 *getlr(); 241 242extern CONSZ rdin(); 243 244extern int eprint(); 245 246extern char *rnames[]; 247 248extern int lineno; 249extern char filename[]; 250extern int fldshf, fldsz; 251extern int lflag, xdebug, udebug, edebug, odebug, rdebug, radebug, tdebug, sdebug; 252#ifdef FORT 253extern int Oflag; 254#endif 255 256#ifndef callchk 257#define callchk(x) allchk() 258#endif 259 260#ifndef PUTCHAR 261# define PUTCHAR(x) putchar(x) 262#endif 263 264 /* macros for doing double indexing */ 265# define R2PACK(x,y,z) (0200*((x)+1)+y+040000*z) 266# define R2UPK1(x) ((((x)>>7)-1)&0177) 267# define R2UPK2(x) ((x)&0177) 268# define R2UPK3(x) (x>>14) 269# define R2TEST(x) ((x)>=0200) 270 271# ifdef MULTILEVEL 272 273union mltemplate{ 274 struct ml_head{ 275 int tag; /* identifies class of tree */ 276 int subtag; /* subclass of tree */ 277 union mltemplate * nexthead; /* linked by mlinit() */ 278 } mlhead; 279 struct ml_node{ 280 int op; /* either an operator or op description */ 281 int nshape; /* shape of node */ 282 /* both op and nshape must match the node. 283 * where the work is to be done entirely by 284 * op, nshape can be SANY, visa versa, op can 285 * be OPANY. 286 */ 287 int ntype; /* type descriptor from mfile2 */ 288 } mlnode; 289 }; 290 291# endif 292