|
|
1.1 ! root 1: /* ! 2: * n3/itree.c ! 3: * C compiler intermediate file printer. ! 4: * Tree handler. ! 5: */ ! 6: ! 7: #ifdef vax ! 8: #include "INC$LIB:cc3.h" ! 9: #else ! 10: #include "cc3.h" ! 11: #endif ! 12: ! 13: /* ! 14: * Print a tree. ! 15: * The 'op' is the temp. file opcode that introduced the tree. ! 16: * The conditional trees must read in the label. ! 17: * The tree is printed between walls, with a title in the first wall. ! 18: */ ! 19: itree(op) ! 20: { ! 21: strcpy(id, ilonames[op]); ! 22: if (op==TEXPR || op==FEXPR) ! 23: sprintf(id, "%s to L" I_FMT, ilonames[op], iget()); ! 24: iwall(id); ! 25: itree1(0); ! 26: fputc('\t', ofp); ! 27: iwall(NULL); ! 28: } ! 29: ! 30: /* ! 31: * Read and print a tree node and its subtrees. ! 32: */ ! 33: itree1(n) ! 34: int n; ! 35: { ! 36: register int i; ! 37: register int op; ! 38: register int type; ! 39: char *opid; ! 40: int seg; ! 41: dval_t dval; ! 42: sizeof_t offs; ! 43: int width, base; ! 44: extern char *milnames[]; ! 45: extern char *mionames[]; ! 46: extern char *mdlnames[]; ! 47: extern char *mdonames[]; ! 48: ! 49: if ((op=iget()) == NIL) ! 50: return; ! 51: fputc('\t', ofp); ! 52: i = n; ! 53: while (i--) ! 54: fputc(' ', ofp); ! 55: if (op < MDLBASE) ! 56: opid = milnames[op]; ! 57: else if (op < MIOBASE) ! 58: opid = mdlnames[op-MDLBASE]; ! 59: else if (op < MDOBASE) ! 60: opid = mionames[op-MIOBASE]; ! 61: else if (op < ETCBASE) ! 62: opid = mdonames[op-MDOBASE]; ! 63: else ! 64: sprintf(opid, "Bad == %d", op); ! 65: type = bget(); ! 66: fprintf(ofp, "%s %s ", opid, tynames[type]); ! 67: if (type == BLK) ! 68: fprintf(ofp, "(" I_FMT " bytes) ", iget()); ! 69: switch (op) { ! 70: ! 71: case ICON: ! 72: fprintf(ofp, I_FMT, iget()); ! 73: break; ! 74: ! 75: case LCON: ! 76: fprintf(ofp, "%ld", lget()); ! 77: break; ! 78: ! 79: case ZCON: ! 80: fprintf(ofp, "%ld", (long)zget()); ! 81: break; ! 82: ! 83: case DCON: ! 84: dget(dval); ! 85: gendval(dval); ! 86: break; ! 87: ! 88: case REG: ! 89: fprintf(ofp, "%s", regnames[iget()]); ! 90: break; ! 91: ! 92: case AID: ! 93: case PID: ! 94: fprintf(ofp, "at %ld", (long)zget()); ! 95: break; ! 96: ! 97: case LID: ! 98: case GID: ! 99: offs = zget(); ! 100: seg = bget(); ! 101: fprintf(ofp, "%s.", segnames[seg]); ! 102: if (op == LID) ! 103: fprintf(ofp, "L%d", (int)iget()); ! 104: else { ! 105: sget(id, NCSYMB); ! 106: fprintf(ofp, "%s", id); ! 107: } ! 108: if (offs != 0) { ! 109: if (offs > 0) ! 110: fputc('+', ofp); ! 111: fprintf(ofp, "%ld", (long)offs); ! 112: } ! 113: break; ! 114: ! 115: case FIELD: ! 116: width = bget(); ! 117: base = bget(); ! 118: fprintf(ofp, "base=%d width=%d\n", base, width); ! 119: itree1(n+2); ! 120: return; ! 121: ! 122: default: ! 123: if (op < MIOBASE) { ! 124: genmdl(op); ! 125: break; ! 126: } else if (op < MDOBASE) { ! 127: fputc('\n', ofp); ! 128: itree1(n+2); /* Left */ ! 129: itree1(n+2); /* Right */ ! 130: return; ! 131: } else { ! 132: genmdo(op); ! 133: return; ! 134: } ! 135: } ! 136: fputc('\n', ofp); ! 137: } ! 138: ! 139: /* ! 140: * Print a wall with the title string 's' in it. ! 141: * The wall is always WIDTH long. ! 142: */ ! 143: iwall(s) ! 144: register char *s; ! 145: { ! 146: register int n; ! 147: n = WIDTH; ! 148: if (s != NULL) { ! 149: fprintf(ofp, "%s ", s); ! 150: n -= strlen(s) + 1; ! 151: } ! 152: while (--n >= 0) ! 153: fputc('-', ofp); ! 154: fputc('\n', ofp); ! 155: } ! 156: ! 157: /* end of n3/itree.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.