|
|
1.1 ! root 1: /* pass2.h 4.4 87/12/10 */ ! 2: ! 3: #ifndef _PASS2_ ! 4: #define _PASS2_ ! 5: ! 6: #include "macdefs.h" ! 7: #include "mac2defs.h" ! 8: #include "manifest.h" ! 9: ! 10: /* cookies, used as arguments to codgen */ ! 11: #define FOREFF 01 /* compute for effects only */ ! 12: #define INAREG 02 /* compute into a register */ ! 13: #define INTAREG 04 /* compute into a scratch register */ ! 14: #define INBREG 010 /* compute into a lvalue register */ ! 15: #define INTBREG 020 /* compute into a scratch lvalue register */ ! 16: #define FORCC 040 /* compute for condition codes only */ ! 17: #define INTEMP 010000 /* compute into a temporary location */ ! 18: #define FORARG 020000 /* compute for an argument of a function */ ! 19: #define FORREW 040000 /* search the table for a rewrite rule */ ! 20: ! 21: /* ! 22: * OP descriptors, ! 23: * the ASG operator may be used on some of these ! 24: */ ! 25: #define OPSIMP 010000 /* +, -, &, |, ^ */ ! 26: #define OPCOMM 010002 /* +, &, |, ^ */ ! 27: #define OPMUL 010004 /* *, / */ ! 28: #define OPDIV 010006 /* /, % */ ! 29: #define OPUNARY 010010 /* unary ops */ ! 30: #define OPLEAF 010012 /* leaves */ ! 31: #define OPANY 010014 /* any op... */ ! 32: #define OPLOG 010016 /* logical ops */ ! 33: #define OPFLOAT 010020 /* +, -, *, or / (for floats) */ ! 34: #define OPSHFT 010022 /* <<, >> */ ! 35: #define OPLTYPE 010024 /* leaf type nodes (e.g, NAME, ICON, etc.) */ ! 36: ! 37: /* match returns */ ! 38: #define MNOPE 010000 /* no match generated */ ! 39: #define MDONE 010001 /* done evalution */ ! 40: ! 41: /* shapes */ ! 42: #define SANY 01 /* same as FOREFF */ ! 43: #define SAREG 02 /* same as INAREG */ ! 44: #define STAREG 04 /* same as INTAREG */ ! 45: #define SBREG 010 /* same as INBREG */ ! 46: #define STBREG 020 /* same as INTBREG */ ! 47: #define SCC 040 /* same as FORCC */ ! 48: #define SNAME 0100 /* name */ ! 49: #define SCON 0200 /* constant */ ! 50: #define SFLD 0400 /* field */ ! 51: #define SOREG 01000 /* offset from register */ ! 52: /* indirection or wild card shapes */ ! 53: #ifndef WCARD1 ! 54: #define STARNM 02000 /* indirect through name */ ! 55: #endif ! 56: #ifndef WCARD2 ! 57: #define STARREG 04000 /* indirect through register */ ! 58: #endif ! 59: #define SWADD 040000 /* word address */ ! 60: #define SPECIAL 0100000 /* special stuff (follows) */ ! 61: #define SZERO SPECIAL /* constant zero */ ! 62: #define SONE (SPECIAL|1) /* constant +1 */ ! 63: #define SMONE (SPECIAL|2) /* constant -1 */ ! 64: #define SCCON (SPECIAL|3) /* -256 <= constant < 256 */ ! 65: #define SSCON (SPECIAL|4) /* -32768 <= constant < 32768 */ ! 66: #define SSOREG (SPECIAL|5) /* non-indexed OREG */ ! 67: #define SMCON (SPECIAL|6) /* constant < 0 */ ! 68: /* FORARG and INTEMP are carefully not conflicting with shapes */ ! 69: ! 70: /* types */ ! 71: #define TCHAR 01 /* char */ ! 72: #define TSHORT 02 /* short */ ! 73: #define TINT 04 /* int */ ! 74: #define TLONG 010 /* long */ ! 75: #define TFLOAT 020 /* float */ ! 76: #define TDOUBLE 040 /* double */ ! 77: #define TPOINT 0100 /* pointer to something */ ! 78: #define TUCHAR 0200 /* unsigned char */ ! 79: #define TUSHORT 0400 /* unsigned short */ ! 80: #define TUNSIGNED 01000 /* unsigned int */ ! 81: #define TULONG 02000 /* unsigned long */ ! 82: #define TPTRTO 04000 /* pointer to one of the above */ ! 83: #define TANY 010000 /* matches anything within reason */ ! 84: #define TSTRUCT 020000 /* structure or union */ ! 85: ! 86: /* reclamation cookies */ ! 87: #define RNULL 0 /* clobber result */ ! 88: #define RLEFT 01 /* reclaim left resource */ ! 89: #define RRIGHT 02 /* reclaim right resource */ ! 90: #define RESC1 04 /* reclaim resource allocated #1 */ ! 91: #define RESC2 010 /* reclaim resource allocated #2 */ ! 92: #define RESC3 020 /* reclaim resource allocated #3 */ ! 93: #define RESCC 04000 /* reclaim condition codes */ ! 94: #define RNOP 010000 /* DANGER: can cause loops.. */ ! 95: ! 96: /* needs */ ! 97: #define NAREG 01 /* need an A register */ ! 98: #define NACOUNT 03 /* count mask of A registers */ ! 99: #define NAMASK 017 /* A register need field mask */ ! 100: #define NASL 04 /* need A register shared with left resource */ ! 101: #define NASR 010 /* need A register shared with right resource */ ! 102: #define NBREG 020 /* need a B register */ ! 103: #define NBCOUNT 060 /* count mask of B register */ ! 104: #define NBMASK 0360 /* B register need field mask */ ! 105: #define NBSL 0100 /* need B register shared with left resource */ ! 106: #define NBSR 0200 /* need B register shared with right resource */ ! 107: #define NTEMP 0400 /* need temporary storage location */ ! 108: #define NTMASK 07400 /* count mask of temporary storage locations */ ! 109: #define REWRITE 010000 /* need rewrite */ ! 110: #define EITHER 040000 /* allocate all resources or nothing */ ! 111: ! 112: #define MUSTDO 010000 /* force register requirements */ ! 113: #ifndef NOPREF ! 114: /* also defined in onepass.h */ ! 115: #define NOPREF 020000 /* no preference for register assignment */ ! 116: #endif ! 117: #define NEVEN 0100000 /* even register required */ ! 118: ! 119: /* register allocation */ ! 120: extern int rstatus[]; /* register status info */ ! 121: extern int busy[]; /* register use info */ ! 122: extern struct respref { ! 123: int cform; ! 124: int mform; ! 125: } respref[]; /* resource preference rules */ ! 126: ! 127: #define isbreg(r) (rstatus[r]&SBREG) ! 128: #define istreg(r) (rstatus[r]&(STBREG|STAREG)) ! 129: #define istnode(p) (p->in.op==REG && istreg(p->tn.rval)) ! 130: ! 131: #define TBUSY 01000 /* register temporarily busy (during alloc) */ ! 132: #define PBUSY 02000 /* this reg and next one are used as a pair */ ! 133: #define ISBUSY(r) (((busy[r])&(PBUSY-1)) > 1) ! 134: #define REGLOOP(i) for (i = 0; i < REGSZ; ++i) ! 135: ! 136: extern NODE *deltrees[DELAYS]; /* trees held for delayed evaluation */ ! 137: extern int deli; /* mmmmm */ ! 138: ! 139: #define SETSTO(x,y) (stotree = (x), stocook = (y)) ! 140: extern int stocook; ! 141: extern NODE *stotree; ! 142: extern int callflag; ! 143: ! 144: extern int fregs; ! 145: ! 146: #ifndef ONEPASS ! 147: #include "ndu.h" ! 148: #endif ! 149: ! 150: extern NODE node[]; ! 151: ! 152: /* code tables */ ! 153: extern struct optab { ! 154: int op; /* operator to match */ ! 155: int visit; /* goal to match */ ! 156: int lshape; /* left shape to match */ ! 157: int ltype; /* left type to match */ ! 158: int rshape; /* right shape to match */ ! 159: int rtype; /* right type to match */ ! 160: int needs; /* resource required */ ! 161: int rewrite; /* how to rewrite afterwards */ ! 162: char *cstring; /* code generation template */ ! 163: } table[]; ! 164: ! 165: extern NODE resc[]; ! 166: ! 167: extern OFFSZ tmpoff; ! 168: extern OFFSZ maxoff; ! 169: extern OFFSZ baseoff; ! 170: extern OFFSZ maxtemp; ! 171: extern int maxtreg; ! 172: extern int ftnno; ! 173: extern int rtyflg; ! 174: extern int nrecur; /* flag to keep track of recursions */ ! 175: ! 176: extern NODE ! 177: *talloc(), ! 178: *eread(), ! 179: *tcopy(), ! 180: *getlr(); ! 181: ! 182: extern CONSZ rdin(); ! 183: extern int eprint(); ! 184: extern char *rnames[]; ! 185: ! 186: extern int lineno; ! 187: extern char filename[]; ! 188: extern int fldshf, fldsz; ! 189: extern int lflag, xdebug, udebug, edebug, odebug; ! 190: extern int rdebug, radebug, tdebug, sdebug; ! 191: #ifdef FORT ! 192: extern int Oflag; ! 193: #endif ! 194: ! 195: #ifndef callchk ! 196: #define callchk(x) allchk() ! 197: #endif ! 198: ! 199: #ifndef PUTCHAR ! 200: #define PUTCHAR(x) putchar(x) ! 201: #endif ! 202: ! 203: /* macros for doing double indexing */ ! 204: #define R2PACK(x,y,z) (0200*((x)+1)+y+040000*z) /* pack 3 regs */ ! 205: #define R2UPK1(x) ((((x)>>7)-1)&0177) /* unpack reg 1 */ ! 206: #define R2UPK2(x) ((x)&0177) /* unpack reg 2 */ ! 207: #define R2UPK3(x) (x>>14) /* unpack reg 3 */ ! 208: #define R2TEST(x) ((x)>=0200) /* test if packed */ ! 209: ! 210: #ifdef MULTILEVEL ! 211: union mltemplate { ! 212: struct ml_head { ! 213: int tag; /* tree class */ ! 214: int subtag; /* subclass of tree */ ! 215: union mltemplate *nexthead; /* linked by mlinit() */ ! 216: } mlhead; ! 217: struct ml_node { ! 218: int op; /* operator or op description */ ! 219: int nshape; /* node shape */ ! 220: /* ! 221: * Both op and nshape must match the node. ! 222: * where the work is to be done entirely by ! 223: * op, nshape can be SANY, visa versa, op can ! 224: * be OPANY. ! 225: */ ! 226: int ntype; /* type descriptor */ ! 227: } mlnode; ! 228: }; ! 229: extern union mltemplate mltree[]; ! 230: #endif ! 231: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.