|
|
1.1 ! root 1: /* ! 2: * C code generator header ! 3: */ ! 4: ! 5: #include <stdio.h> ! 6: #include <setjmp.h> ! 7: ! 8: #define LTYPE long /* change to int for no long consts */ ! 9: #define NCPS 8 ! 10: #define NULL 0 ! 11: #define TNULL (union tree *)NULL ! 12: #define UNS(x) ((unsigned short)(x)) ! 13: ! 14: /* ! 15: * Tree node for unary and binary ! 16: */ ! 17: struct tnode { ! 18: int op; ! 19: int type; ! 20: int degree; ! 21: union tree *tr1; ! 22: union tree *tr2; ! 23: }; ! 24: ! 25: /* ! 26: * tree names for locals ! 27: */ ! 28: struct tname { ! 29: int op; ! 30: int type; ! 31: char class; ! 32: char regno; ! 33: int offset; ! 34: int nloc; ! 35: }; ! 36: ! 37: /* ! 38: * tree names for externals ! 39: */ ! 40: struct xtname { ! 41: int op; ! 42: int type; ! 43: char class; ! 44: char regno; ! 45: int offset; ! 46: char name[NCPS]; ! 47: }; ! 48: ! 49: /* ! 50: * short constants ! 51: */ ! 52: struct tconst { ! 53: int op; ! 54: int type; ! 55: int value; ! 56: }; ! 57: ! 58: /* ! 59: * long constants ! 60: */ ! 61: struct lconst { ! 62: int op; ! 63: int type; ! 64: LTYPE lvalue; ! 65: }; ! 66: ! 67: /* ! 68: * Floating constants ! 69: */ ! 70: struct ftconst { ! 71: int op; ! 72: int type; ! 73: int value; ! 74: double fvalue; ! 75: }; ! 76: ! 77: /* ! 78: * Node used for field assignments ! 79: */ ! 80: struct fasgn { ! 81: int op; ! 82: int type; ! 83: int degree; ! 84: union tree *tr1; ! 85: union tree *tr2; ! 86: int mask; ! 87: }; ! 88: ! 89: union tree { ! 90: struct tnode t; ! 91: struct tname n; ! 92: struct xtname x; ! 93: struct tconst c; ! 94: struct lconst l; ! 95: struct ftconst f; ! 96: struct fasgn F; ! 97: }; ! 98: ! 99: struct optab { ! 100: char tabdeg1; ! 101: char tabtyp1; ! 102: char tabdeg2; ! 103: char tabtyp2; ! 104: char *tabstring; ! 105: }; ! 106: ! 107: struct table { ! 108: int tabop; ! 109: struct optab *tabp; ! 110: }; ! 111: ! 112: struct instab { ! 113: int iop; ! 114: char *str1; ! 115: char *str2; ! 116: }; ! 117: ! 118: struct swtab { ! 119: int swlab; ! 120: int swval; ! 121: }; ! 122: ! 123: char maprel[]; ! 124: char notrel[]; ! 125: int nreg; ! 126: int isn; ! 127: int line; ! 128: int nerror; ! 129: struct table cctab[]; ! 130: struct table efftab[]; ! 131: struct table regtab[]; ! 132: struct table sptab[]; ! 133: struct table lsptab[1]; ! 134: struct instab instab[]; ! 135: struct instab branchtab[]; ! 136: int opdope[]; ! 137: char *opntab[]; ! 138: int nstack; ! 139: int nfloat; ! 140: struct tname sfuncr; ! 141: char *funcbase; ! 142: char *curbase; ! 143: char *coremax; ! 144: struct tconst czero, cone; ! 145: long totspace; ! 146: int regpanic; /* set when SU register alg. fails */ ! 147: int panicposs; /* set when there might be a need for regpanic */ ! 148: jmp_buf jmpbuf; ! 149: long ftell(); ! 150: char *sbrk(); ! 151: struct optab *match(); ! 152: union tree *optim(); ! 153: union tree *unoptim(); ! 154: union tree *pow2(); ! 155: union tree *tnode(); ! 156: union tree *sdelay(); ! 157: union tree *ncopy(); ! 158: union tree *getblk(); ! 159: union tree *strfunc(); ! 160: union tree *isconstant(); ! 161: union tree *tconst(); ! 162: union tree *hardlongs(); ! 163: union tree *lconst(); ! 164: union tree *acommute(); ! 165: union tree *lvfield(); ! 166: union tree *paint(); ! 167: long ftell(); ! 168: ! 169: /* ! 170: * Some special stuff for long comparisons ! 171: */ ! 172: int xlab1, xlab2, xop, xzero; ! 173: ! 174: /* ! 175: operators ! 176: */ ! 177: #define EOFC 0 ! 178: #define SEMI 1 ! 179: #define LBRACE 2 ! 180: #define RBRACE 3 ! 181: #define LBRACK 4 ! 182: #define RBRACK 5 ! 183: #define LPARN 6 ! 184: #define RPARN 7 ! 185: #define COLON 8 ! 186: #define COMMA 9 ! 187: #define FSEL 10 ! 188: #define FSELR 11 ! 189: #define FSELT 12 ! 190: #define FSELA 16 ! 191: #define ULSH 17 ! 192: #define ASULSH 18 ! 193: ! 194: #define KEYW 19 ! 195: #define NAME 20 ! 196: #define CON 21 ! 197: #define STRING 22 ! 198: #define FCON 23 ! 199: #define SFCON 24 ! 200: #define LCON 25 ! 201: #define SLCON 26 ! 202: ! 203: #define AUTOI 27 ! 204: #define AUTOD 28 ! 205: #define NULLOP 218 ! 206: #define INCBEF 30 ! 207: #define DECBEF 31 ! 208: #define INCAFT 32 ! 209: #define DECAFT 33 ! 210: #define EXCLA 34 ! 211: #define AMPER 35 ! 212: #define STAR 36 ! 213: #define NEG 37 ! 214: #define COMPL 38 ! 215: ! 216: #define DOT 39 ! 217: #define PLUS 40 ! 218: #define MINUS 41 ! 219: #define TIMES 42 ! 220: #define DIVIDE 43 ! 221: #define MOD 44 ! 222: #define RSHIFT 45 ! 223: #define LSHIFT 46 ! 224: #define AND 47 ! 225: #define ANDN 55 ! 226: #define OR 48 ! 227: #define EXOR 49 ! 228: #define ARROW 50 ! 229: #define ITOF 51 ! 230: #define FTOI 52 ! 231: #define LOGAND 53 ! 232: #define LOGOR 54 ! 233: #define FTOL 56 ! 234: #define LTOF 57 ! 235: #define ITOL 58 ! 236: #define LTOI 59 ! 237: #define ITOP 13 ! 238: #define PTOI 14 ! 239: #define LTOP 15 ! 240: ! 241: #define EQUAL 60 ! 242: #define NEQUAL 61 ! 243: #define LESSEQ 62 ! 244: #define LESS 63 ! 245: #define GREATEQ 64 ! 246: #define GREAT 65 ! 247: #define LESSEQP 66 ! 248: #define LESSP 67 ! 249: #define GREATQP 68 ! 250: #define GREATP 69 ! 251: ! 252: #define ASPLUS 70 ! 253: #define ASMINUS 71 ! 254: #define ASTIMES 72 ! 255: #define ASDIV 73 ! 256: #define ASMOD 74 ! 257: #define ASRSH 75 ! 258: #define ASLSH 76 ! 259: #define ASAND 77 ! 260: #define ASOR 78 ! 261: #define ASXOR 79 ! 262: #define ASSIGN 80 ! 263: #define TAND 81 ! 264: #define LTIMES 82 ! 265: #define LDIV 83 ! 266: #define LMOD 84 ! 267: #define ASANDN 85 ! 268: #define LASTIMES 86 ! 269: #define LASDIV 87 ! 270: #define LASMOD 88 ! 271: ! 272: #define QUEST 90 ! 273: #define MAX 93 ! 274: #define MAXP 94 ! 275: #define MIN 95 ! 276: #define MINP 96 ! 277: #define LLSHIFT 91 ! 278: #define ASLSHL 92 ! 279: #define SEQNC 97 ! 280: #define CALL1 98 ! 281: #define CALL2 99 ! 282: #define CALL 100 ! 283: #define MCALL 101 ! 284: #define JUMP 102 ! 285: #define CBRANCH 103 ! 286: #define INIT 104 ! 287: #define SETREG 105 ! 288: #define LOAD 106 ! 289: #define PTOI1 107 ! 290: #define ITOC 109 ! 291: #define RFORCE 110 ! 292: ! 293: /* ! 294: * Intermediate code operators ! 295: */ ! 296: #define BRANCH 111 ! 297: #define LABEL 112 ! 298: #define NLABEL 113 ! 299: #define RLABEL 114 ! 300: #define STRASG 115 ! 301: #define STRSET 116 ! 302: #define UDIV 117 ! 303: #define UMOD 118 ! 304: #define ASUDIV 119 ! 305: #define ASUMOD 120 ! 306: ! 307: #define BDATA 200 ! 308: #define PROG 202 ! 309: #define DATA 203 ! 310: #define BSS 204 ! 311: #define CSPACE 205 ! 312: #define SSPACE 206 ! 313: #define SYMDEF 207 ! 314: #define SAVE 208 ! 315: #define RETRN 209 ! 316: #define EVEN 210 ! 317: #define PROFIL 212 ! 318: #define SWIT 213 ! 319: #define EXPR 214 ! 320: #define SNAME 215 ! 321: #define RNAME 216 ! 322: #define ANAME 217 ! 323: #define SETSTK 219 ! 324: #define SINIT 220 ! 325: #define GLOBAL 221 ! 326: #define C3BRANCH 222 ! 327: ! 328: /* ! 329: * types ! 330: */ ! 331: #define INT 0 ! 332: #define CHAR 1 ! 333: #define FLOAT 2 ! 334: #define DOUBLE 3 ! 335: #define STRUCT 4 ! 336: #define RSTRUCT 5 ! 337: #define LONG 6 ! 338: #define UNSIGN 7 ! 339: #define UNCHAR 8 ! 340: #define UNLONG 9 ! 341: #define VOID 10 ! 342: ! 343: #define TYLEN 2 ! 344: #define TYPE 017 ! 345: #define XTYPE (03<<4) ! 346: #define PTR 020 ! 347: #define FUNC 040 ! 348: #define ARRAY 060 ! 349: ! 350: /* ! 351: storage classes ! 352: */ ! 353: #define KEYWC 1 ! 354: #define MOS 10 ! 355: #define AUTO 11 ! 356: #define EXTERN 12 ! 357: #define STATIC 13 ! 358: #define REG 14 ! 359: #define STRTAG 15 ! 360: #define ARG 16 ! 361: #define OFFS 20 ! 362: #define XOFFS 21 ! 363: #define SOFFS 22 ! 364: ! 365: /* ! 366: Flag bits ! 367: */ ! 368: ! 369: #define BINARY 01 ! 370: #define LVALUE 02 ! 371: #define RELAT 04 ! 372: #define ASSGOP 010 ! 373: #define LWORD 020 ! 374: #define RWORD 040 ! 375: #define COMMUTE 0100 ! 376: #define RASSOC 0200 ! 377: #define LEAF 0400 ! 378: #define CNVRT 01000
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.