|
|
1.1 root 1: /*
2: * n1/i386/reg1.c
3: * Machine specific parts of the register allocator.
4: * i386.
5: */
6:
7: #ifdef vax
8: #include "INC$LIB:cc1.h"
9: #else
10: #include "cc1.h"
11: #endif
12:
13: /*
14: * Select a register.
15: * The argument 'tp' is the tree.
16: * The argument 'c' is a context, which will be either 'PAIR' or 'ANY'.
17: * The 'flag' is true if ANY should be resolved.
18: */
19: regselect(tp, c, flag) TREE *tp; int c, flag;
20: {
21: register REGDESC *rp;
22: register KIND kind;
23: register PREGSET busy;
24: register PERTYPE *ptp;
25:
26: ptp = &pertype[tp->t_type];
27: if (c == PAIR)
28: kind = ptp->p_pair;
29: else if (flag==0)
30: return c;
31: kind = ptp->p_kind;
32: busy = curbusy;
33: for (rp = ®[FRREG]; rp<®[NRREG]; ++rp) {
34: if ((rp->r_phys&busy) != 0)
35: continue;
36: if (c == ANYL) {
37: if ((rp->r_lvalue&kind) == 0)
38: continue;
39: } else {
40: if ((rp->r_rvalue&kind) == 0)
41: continue;
42: }
43: if (bytereg(tp, tp->t_patp) && (rp->r_phys&~(BEAX|BEBX|BECX|BEDX))!=0)
44: continue;
45: return (rp - ®[0]);
46: }
47: return -1;
48: }
49:
50: /*
51: * Return true if register 'r' is a usable temporary for tree 'tp'.
52: */
53: isusable(tp, c, r) register TREE *tp; int c; register int r;
54: {
55: register int op;
56: register KIND kind;
57:
58: #if !TINY
59: if (sflag > 2)
60: snapf("Isusable(%P, %C, %R)? ", tp, c, r);
61: #endif
62: op = tp->t_op;
63: kind = pertype[tp->t_type].p_kind;
64: if (c == MLVALUE) {
65: if ((reg[r].r_lvalue&kind) == 0)
66: goto no;
67: } else {
68: if ((reg[r].r_rvalue&kind) == 0)
69: goto no;
70: }
71: if (bytereg(tp, tp->t_patp) && (reg[r].r_phys&~(BEAX|BEBX|BECX|BEDX))!=0)
72: goto no;
73: #if !TINY
74: if (sflag > 2)
75: snapf("yes\n");
76: #endif
77: return 1;
78: no:
79: #if !TINY
80: if (sflag > 2)
81: snapf("no\n");
82: #endif
83: return 0;
84: }
85:
86: /*
87: * Test if a pattern requires a byte register.
88: * This prevents e.g. applying the LO LO macro to EDI or ESI.
89: * The first argument is archaic.
90: * dgc kludged the i8086 compiler source to look at tp
91: * to decide if the tree needed a byte register.
92: * steve added the PBYTE pattern flag for the i386 compiler,
93: * so bytereg() now looks at the pattern instead of at the tree.
94: * Only patterns with BYTE left or right arg types require byte registers.
95: * The tp argument is retained to maintain compatiblity
96: * with other machine-dependent sources, namely i8086.
97: */
98: int
99: bytereg(tp, patp) register TREE *tp; register PAT *patp;
100: {
101: register INDEX index;
102: register TREE *rp;
103:
104: index = patp->p_flag;
105: return (index != 0 && (patcache[index-1] & PBYTE) != 0
106: && (isbyte(tp->t_lp->t_type)
107: || ((rp = tp->t_rp) != NULL && isbyte(rp->t_type))));
108: }
109:
110: /* end of n1/i386/reg1.c */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.