|
|
1.1 root 1: /* @(#) mfile2.h: 1.1 12/22/83 */
2:
3: # include "macdefs.h"
4: # include "manifest.h"
5:
6: /* code generation goals, used in table entries */
7:
8: # define FOREFF 01 /* compute for effects only */
9: # define INREG 02 /* compute into a register */
10: # define FORCC 04 /* compute for condition codes only */
11:
12: /* types of operators and shapes; optab.tyop, optab.ltype optab.rtype */
13: # define TCHAR 01
14: # define TUCHAR 0100
15: # define TSHORT 02
16: # define TUSHORT 0200
17: # define TLONG 010
18: # define TULONG 01000
19:
20: /* make INT match SHORT, LONG, or both depending on NOSHORT, NOLONG */
21: # define urTINT 04
22: # define urTUNSIGNED 0400
23:
24: # ifdef NOSHORT
25: /* shorts == ints */
26: # ifdef NOLONG
27: /* longs == ints */
28: # define TINT (urTINT|TSHORT|TLONG)
29: # define TUNSIGNED (urTUNSIGNED|TUSHORT|TULONG)
30: # else
31: /* longs != ints, and shorts == ints */
32: # define TINT (urTINT|TSHORT)
33: # define TUNSIGNED (urTUNSIGNED|TUSHORT)
34: # endif
35: # else
36: /* shorts != ints */
37: # ifdef NOLONG
38: /* longs == ints */
39: # define TINT (urTINT|TLONG)
40: # define TUNSIGNED (urTUNSIGNED|TULONG)
41: # else
42: /* longs, shorts, and ints all distinct */
43: # define TINT urTINT
44: # define TUNSIGNED urTUNSIGNED
45: # endif
46: # endif
47:
48: # define TDOUBLE 040
49: /* handle floats: match doubles if ONEFLOAT */
50: # ifdef ONEFLOAT
51: /* floats are the same as doubles in this case */
52: # define TFLOAT (TDOUBLE|020)
53: # else
54: # define TFLOAT 020
55: # endif
56:
57: # define TSTRUCT 02000 /* structure or union */
58: # define TPOINT 04000
59: # define TPOINT2 010000
60: # define TVOID 020000
61: # define TANY 077777 /* matches anything within reason */
62: /* 0100000 (SPTYPE) is reserved for matches */
63:
64: /* reclamation cookies */
65:
66: # define RLEFT 01
67: # define RRIGHT 02
68: # define RESC1 04
69: # define RESC2 010
70: # define RESC3 020
71: # define RESCC 040
72: # define RNOP 0100 /* DANGER: can cause loops.. */
73: # define RNULL 0200 /* clobber result */
74:
75: /* needs */
76:
77: # define NREG 01
78: # define NCOUNT 017
79: # define NMASK 0777
80: # define LSHARE 020 /* share left register */
81: # define RSHARE 040 /* share right register */
82: # define NPAIR 0100 /* allocate registers in pairs */
83: # define LPREF 0200 /* prefer left register, if any */
84: # define RPREF 0400 /* prefer right register, if any */
85:
86: /* register allocation */
87:
88: extern int busy[];
89:
90: # define INFINITY 10000
91:
92: extern NODE node[];
93:
94: typedef struct shape SHAPE;
95:
96: /* special shapes (enforced by making costs high) */
97: # define SPECIAL 0170000
98: # define SPTYPE 0100000
99: # define STMASK 070000
100: # define SVAL 010000 /* positive constant value */
101: # define SNVAL 020000 /* negative constant value */
102: # define SRANGE0 030000 /* positive range [0, 2**mm - 1] */
103: # define SSRANGE 040000 /* signed range [-2**mm, 2**mm] */
104: # define NACON 050000 /* nameless contant */
105: # define SUSER 070000 /* user's cost function */
106: # define SVMASK 07777 /* shape value mask */
107:
108: extern struct shape {
109: int op; /* operator */
110: SHAPE *sl; /* pointers to left- and right-hand shape */
111: SHAPE *sr;
112: int sh; /* flags for special shape and type matches */
113: int sc; /* cost of applying this shape */
114: } shapes[];
115: extern SHAPE *pshape[];
116:
117: typedef struct optab OPTAB;
118:
119: struct optab {
120: int op; /* operator */
121: int tyop; /* type of the operator node itself */
122: OPTAB *nextop;
123: SHAPE **lshape; /* pointer to pointer to left shape */
124: int ltype; /* type of left shape */
125: SHAPE **rshape; /* likewise for the right shape */
126: int rtype;
127: int needs;
128: int rewrite;
129: char *cstring;
130: int cost;
131: int lcount; /* number of times left used */
132: int rcount; /* number of times right used */
133: int stinline; /* line number in stin file */
134: };
135:
136: extern OPTAB
137: *match(),
138: *ophead[],
139: table[];
140:
141: extern NODE resc[];
142:
143: extern int tmpoff;
144: extern int maxboff;
145: extern int maxtemp;
146: extern int maxarg;
147: extern int ftnno;
148: extern int sideff;
149:
150: extern NODE
151: *talloc(),
152: *ind2type(),
153: *tcopy(),
154: *getadr(),
155: *getlr();
156:
157: # define getlt(p,t) ((t)==LTYPE?p:p->in.left)
158: # define getlo(p,o) (getlt(p,optype(o)))
159: # define getl(p) (getlo(p,p->tn.op))
160: # define getrt(p,t) ((t)==BITYPE?p->in.right:p)
161: # define getro(p,o) (getrt(p,optype(o)))
162: # define getr(p) (getro(p,p->tn.op))
163:
164: extern CONSZ rdin();
165:
166: extern char *rnames[];
167:
168: extern int lineno;
169: extern char ftitle[];
170: extern int fldshf, fldsz;
171: extern int lflag, udebug, e2debug, odebug, rdebug, radebug, sdebug;
172: extern int fast; /* try to make the compiler run faster */
173:
174: #ifndef callchk
175: #define callchk(x) allchk()
176: #endif
177: #ifndef callreg
178: /* try to number so results returned in 0 */
179: #define callreg(x) 0
180: #endif
181: #ifndef szty
182: /* it would be nice if number of registers to hold type t were 1 */
183: /* on most machines, this will be overridden in macdefs.h */
184: # define szty(t) 1
185: #endif
186:
187:
188: #ifndef PUTCHAR
189: # define PUTCHAR(x) putchar(x)
190: #endif
191:
192: # define CEFF (NRGS+1)
193: # define CTEMP (NRGS+2)
194: # define CCC (NRGS+3)
195: /* the assumption is that registers 0 through NRGS-1 are scratch */
196: /* the others are real */
197: /* some are used for args and temps, etc... */
198:
199: # define istreg(r) ((r)<NRGS)
200:
201: typedef struct inst INST;
202:
203: struct inst {
204: NODE *p;
205: OPTAB *q;
206: int goal;
207: };
208:
209: # define NINS 300
210: extern INST inst[NINS];
211: extern nins;
212:
213: /* definitions of strategies legal for ops */
214:
215: # define STORE 01
216: # define LTOR 02
217: # define RTOL 04
218:
219: /* shape matching */
220: # ifndef NSHP
221: # define NSHP 20
222: # endif
223:
224: typedef SHAPE *SHTABLE[2][NSHP];
225:
226: extern SHTABLE sha;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.