|
|
1.1 ! root 1: /* ! 2: * Machine specific parts of the register allocator. ! 3: * Intel iAPX-86, SMALL and LARGE models. ! 4: */ ! 5: #ifdef vax ! 6: #include "INC$LIB:cc1.h" ! 7: #else ! 8: #include "cc1.h" ! 9: #endif ! 10: ! 11: /* ! 12: * Select a register. ! 13: * The argument 'tp' is the tree. ! 14: * The argument 'c' is a context, ! 15: * which will be either 'PAIR' or 'ANY'. ! 16: * The 'flag' is true if ANY should be resolved. ! 17: */ ! 18: regselect(tp, c, flag) ! 19: TREE *tp; ! 20: { ! 21: register REGDESC *rp; ! 22: register KIND kind; ! 23: register PREGSET busy; ! 24: register int byte; ! 25: register PERTYPE *ptp; ! 26: ! 27: ptp = &pertype[tp->t_type]; ! 28: kind = ptp->p_pair; ! 29: byte = bytereg(tp); ! 30: if (c != PAIR) { ! 31: if (flag==0 && byte==0) ! 32: return (c); ! 33: kind = ptp->p_kind; ! 34: } ! 35: busy = curbusy; ! 36: for (rp = ®[FRREG]; rp<®[NRREG]; ++rp) { ! 37: if ((rp->r_phys&busy) != 0) ! 38: continue; ! 39: if (c == ANYL) { ! 40: if ((rp->r_lvalue&kind) == 0) ! 41: continue; ! 42: } else { ! 43: if ((rp->r_rvalue&kind) == 0) ! 44: continue; ! 45: } ! 46: if (byte && (rp->r_phys&~(BAX|BBX|BCX|BDX))!=0) ! 47: continue; ! 48: return (rp - ®[0]); ! 49: } ! 50: return (-1); ! 51: } ! 52: ! 53: /* ! 54: * This routine returns true if register 'r' ! 55: * is a usable temporary for tree 'tp'. ! 56: */ ! 57: isusable(tp, c, r) ! 58: register TREE *tp; ! 59: register int r; ! 60: { ! 61: register int op; ! 62: register PERTYPE *ptp; ! 63: register KIND kind; ! 64: register int byte; ! 65: ! 66: #if !TINY ! 67: if (sflag > 2) ! 68: snapf("Isusable(%P, %C, %R)? ", tp, c, r); ! 69: #endif ! 70: op = tp->t_op; ! 71: if ((op==SHR || op==SHL || op==ASHR || op==ASHL) ! 72: && (reg[r].r_phys&BCX) != 0) ! 73: goto no; ! 74: ptp = &pertype[tp->t_type]; ! 75: if ((op>=MUL && op<=REM) || (op>=AMUL && op<=AREM)) ! 76: kind = ptp->p_pair; ! 77: else ! 78: kind = ptp->p_kind; ! 79: byte = bytereg(tp); ! 80: if (c == MLVALUE) { ! 81: if ((reg[r].r_lvalue&kind) == 0) ! 82: goto no; ! 83: } else { ! 84: if ((reg[r].r_rvalue&kind) == 0) ! 85: goto no; ! 86: } ! 87: if (byte && (reg[r].r_phys&~(BAX|BBX|BCX|BDX))!=0) ! 88: goto no; ! 89: #if !TINY ! 90: if (sflag > 2) ! 91: snapf("yes\n"); ! 92: #endif ! 93: return (1); ! 94: no: ! 95: #if !TINY ! 96: if (sflag > 2) ! 97: snapf("no\n"); ! 98: #endif ! 99: return (0); ! 100: } ! 101: ! 102: /* ! 103: * Test if a byte register is ! 104: * needed. ! 105: */ ! 106: bytereg(tp) ! 107: register TREE *tp; ! 108: { ! 109: register op; ! 110: ! 111: if (isbyte(tp->t_type)) ! 112: return (1); ! 113: if ((op = tp->t_op)==LEAF || op==CONVERT || op==CAST) ! 114: tp = tp->t_lp; ! 115: if (isbyte(tp->t_type)) ! 116: return (1); ! 117: if ((op==ASSIGN || (op>=AADD && op<=ASHR)) && isbyte(tp->t_lp->t_type)) ! 118: return (1); ! 119: return (0); ! 120: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.