1 | /* $Id: macdefs.h,v 1.12 2010/09/21 05:43:59 ragge Exp $ */
|
---|
2 | /*
|
---|
3 | * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | * 1. Redistributions of source code must retain the above copyright
|
---|
10 | * notice, this list of conditions and the following disclaimer.
|
---|
11 | * 2. Redistributions in binary form must reproduce the above copyright
|
---|
12 | * notice, this list of conditions and the following disclaimer in the
|
---|
13 | * documentation and/or other materials provided with the distribution.
|
---|
14 | * 3. The name of the author may not be used to endorse or promote products
|
---|
15 | * derived from this software without specific prior written permission
|
---|
16 | *
|
---|
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
27 | */
|
---|
28 |
|
---|
29 | /*
|
---|
30 | * MIPS port by Jan Enoksson (janeno-1@student.ltu.se) and
|
---|
31 | * Simon Olsson (simols-1@student.ltu.se) 2005.
|
---|
32 | */
|
---|
33 |
|
---|
34 | /*
|
---|
35 | * Machine-dependent defines for both passes.
|
---|
36 | */
|
---|
37 |
|
---|
38 | #if TARGOS == netbsd
|
---|
39 | #define USE_GAS
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | /*
|
---|
43 | * Convert (multi-)character constant to integer.
|
---|
44 | * Assume: If only one value; store at left side (char size), otherwise
|
---|
45 | * treat it as an integer.
|
---|
46 | */
|
---|
47 | #define makecc(val,i) lastcon = (lastcon<<8)|((val<<24)>>24);
|
---|
48 |
|
---|
49 | #define ARGINIT (16*8) /* # bits above fp where arguments start */
|
---|
50 | #define AUTOINIT (0) /* # bits below fp where automatics start */
|
---|
51 |
|
---|
52 | /*
|
---|
53 | * Storage space requirements
|
---|
54 | */
|
---|
55 | #define SZCHAR 8
|
---|
56 | #define SZBOOL 32
|
---|
57 | #define SZINT 32
|
---|
58 | #define SZFLOAT 32
|
---|
59 | #define SZDOUBLE 64
|
---|
60 | #define SZLDOUBLE 64
|
---|
61 | #define SZLONG 32
|
---|
62 | #define SZSHORT 16
|
---|
63 | #define SZLONGLONG 64
|
---|
64 | #define SZPOINT(t) 32
|
---|
65 |
|
---|
66 | /*
|
---|
67 | * Alignment constraints
|
---|
68 | */
|
---|
69 | #define ALCHAR 8
|
---|
70 | #define ALBOOL 32
|
---|
71 | #define ALINT 32
|
---|
72 | #define ALFLOAT 32
|
---|
73 | #define ALDOUBLE 64
|
---|
74 | #define ALLDOUBLE 64
|
---|
75 | #define ALLONG 32
|
---|
76 | #define ALLONGLONG 64
|
---|
77 | #define ALSHORT 16
|
---|
78 | #define ALPOINT 32
|
---|
79 | #define ALSTRUCT 64
|
---|
80 | #define ALSTACK 32
|
---|
81 |
|
---|
82 | /*
|
---|
83 | * Min/max values.
|
---|
84 | */
|
---|
85 | #define MIN_CHAR -128
|
---|
86 | #define MAX_CHAR 127
|
---|
87 | #define MAX_UCHAR 255
|
---|
88 | #define MIN_SHORT -32768
|
---|
89 | #define MAX_SHORT 32767
|
---|
90 | #define MAX_USHORT 65535
|
---|
91 | #define MIN_INT -1
|
---|
92 | #define MAX_INT 0x7fffffff
|
---|
93 | #define MAX_UNSIGNED 0xffffffff
|
---|
94 | #define MIN_LONG MIN_INT
|
---|
95 | #define MAX_LONG MAX_INT
|
---|
96 | #define MAX_ULONG MAX_UNSIGNED
|
---|
97 | #define MIN_LONGLONG 0x8000000000000000LL
|
---|
98 | #define MAX_LONGLONG 0x7fffffffffffffffLL
|
---|
99 | #define MAX_ULONGLONG 0xffffffffffffffffULL
|
---|
100 |
|
---|
101 | #undef CHAR_UNSIGNED
|
---|
102 | #define BOOL_TYPE INT
|
---|
103 |
|
---|
104 | /*
|
---|
105 | * Use large-enough types.
|
---|
106 | */
|
---|
107 | typedef long long CONSZ;
|
---|
108 | typedef unsigned long long U_CONSZ;
|
---|
109 | typedef long long OFFSZ;
|
---|
110 |
|
---|
111 | #define CONFMT "%lld" /* format for printing constants */
|
---|
112 | #ifdef USE_GAS
|
---|
113 | #define LABFMT "$L%d" /* format for printing labels */
|
---|
114 | #define STABLBL "$LL%d" /* format for stab (debugging) labels */
|
---|
115 | #else
|
---|
116 | #define LABFMT "L%d" /* format for printing labels */
|
---|
117 | #define STABLBL "LL%d" /* format for stab (debugging) labels */
|
---|
118 | #endif
|
---|
119 |
|
---|
120 | #define BACKAUTO /* stack grows negatively for automatics */
|
---|
121 | #define BACKTEMP /* stack grows negatively for temporaries */
|
---|
122 |
|
---|
123 | #undef FIELDOPS /* no bit-field instructions */
|
---|
124 | #define RTOLBYTES 1 /* bytes are numbered right to left */
|
---|
125 |
|
---|
126 | #define ENUMSIZE(high,low) INT /* enums are always stored in full int */
|
---|
127 |
|
---|
128 | /* Definitions mostly used in pass2 */
|
---|
129 |
|
---|
130 | #define BYTEOFF(x) ((x)&03)
|
---|
131 | #define BITOOR(x) (x) /* bit offset to oreg offset */
|
---|
132 |
|
---|
133 | #define szty(t) (((t) == DOUBLE || (t) == LDOUBLE || \
|
---|
134 | DEUNSIGN(t) == LONGLONG) ? 2 : 1)
|
---|
135 |
|
---|
136 | /*
|
---|
137 | * Register names. These must match rnames[] and rstatus[] in local2.c.
|
---|
138 | */
|
---|
139 | #define ZERO 0
|
---|
140 | #define AT 1
|
---|
141 | #define V0 2
|
---|
142 | #define V1 3
|
---|
143 | #define A0 4
|
---|
144 | #define A1 5
|
---|
145 | #define A2 6
|
---|
146 | #define A3 7
|
---|
147 | #define A4 8
|
---|
148 | #define A5 9
|
---|
149 | #define A6 10
|
---|
150 | #define A7 11
|
---|
151 | #if defined(MIPS_N32) || defined(MIPS_N64)
|
---|
152 | #define T0 12
|
---|
153 | #define T1 13
|
---|
154 | #define T2 14
|
---|
155 | #define T3 15
|
---|
156 | #else
|
---|
157 | #define T0 8
|
---|
158 | #define T1 9
|
---|
159 | #define T2 10
|
---|
160 | #define T3 11
|
---|
161 | #endif
|
---|
162 | #define T4 12
|
---|
163 | #define T5 13
|
---|
164 | #define T6 14
|
---|
165 | #define T7 15
|
---|
166 | #define S0 16
|
---|
167 | #define S1 17
|
---|
168 | #define S2 18
|
---|
169 | #define S3 19
|
---|
170 | #define S4 20
|
---|
171 | #define S5 21
|
---|
172 | #define S6 22
|
---|
173 | #define S7 23
|
---|
174 | #define T8 24
|
---|
175 | #define T9 25
|
---|
176 | #define K0 26
|
---|
177 | #define K1 27
|
---|
178 | #define GP 28
|
---|
179 | #define SP 29
|
---|
180 | #define FP 30
|
---|
181 | #define RA 31
|
---|
182 |
|
---|
183 | #define V0V1 32
|
---|
184 | #define A0A1 33
|
---|
185 | #define A1A2 34
|
---|
186 | #define A2A3 35
|
---|
187 |
|
---|
188 | /* we just use o32 naming here, but it works ok for n32/n64 */
|
---|
189 | #define A3T0 36
|
---|
190 | #define T0T1 37
|
---|
191 | #define T1T2 38
|
---|
192 | #define T2T3 39
|
---|
193 | #define T3T4 40
|
---|
194 | #define T4T5 41
|
---|
195 | #define T5T6 42
|
---|
196 | #define T6T7 43
|
---|
197 | #define T7T8 44
|
---|
198 |
|
---|
199 | #define T8T9 45
|
---|
200 | #define S0S1 46
|
---|
201 | #define S1S2 47
|
---|
202 | #define S2S3 48
|
---|
203 | #define S3S4 49
|
---|
204 | #define S4S5 50
|
---|
205 | #define S5S6 51
|
---|
206 | #define S6S7 52
|
---|
207 |
|
---|
208 | #define F0 53
|
---|
209 | #define F2 54
|
---|
210 | #define F4 55
|
---|
211 | #define F6 56
|
---|
212 | #define F8 57
|
---|
213 | #define F10 58
|
---|
214 | #define F12 59
|
---|
215 | #define F14 60
|
---|
216 | #define F16 61
|
---|
217 | #define F18 62
|
---|
218 | #define F20 63
|
---|
219 | /* and the rest for later */
|
---|
220 | #define F22 64
|
---|
221 | #define F24 65
|
---|
222 | #define F26 66
|
---|
223 | #define F28 67
|
---|
224 | #define F30 68
|
---|
225 |
|
---|
226 | #define MAXREGS 64
|
---|
227 | #define NUMCLASS 3
|
---|
228 |
|
---|
229 | #define RETREG(x) (DEUNSIGN(x) == LONGLONG ? V0V1 : \
|
---|
230 | (x) == DOUBLE || (x) == LDOUBLE || (x) == FLOAT ? \
|
---|
231 | F0 : V0)
|
---|
232 | #define FPREG FP /* frame pointer */
|
---|
233 |
|
---|
234 | #define MIPS_N32_NARGREGS 8
|
---|
235 | #define MIPS_O32_NARGREGS 4
|
---|
236 |
|
---|
237 | #define RSTATUS \
|
---|
238 | 0, 0, \
|
---|
239 | SAREG|TEMPREG, SAREG|TEMPREG, \
|
---|
240 | SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
|
---|
241 | SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
|
---|
242 | SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
|
---|
243 | SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \
|
---|
244 | SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \
|
---|
245 | SAREG|TEMPREG, SAREG|TEMPREG, \
|
---|
246 | 0, 0, \
|
---|
247 | 0, 0, 0, 0, \
|
---|
248 | \
|
---|
249 | SBREG|TEMPREG, \
|
---|
250 | SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, \
|
---|
251 | SBREG|TEMPREG, \
|
---|
252 | SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, \
|
---|
253 | SBREG|TEMPREG, SBREG|TEMPREG, \
|
---|
254 | SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, \
|
---|
255 | SBREG, SBREG, SBREG, SBREG, \
|
---|
256 | SBREG, SBREG, SBREG, \
|
---|
257 | SCREG, SCREG, SCREG, SCREG, \
|
---|
258 | SCREG, SCREG, SCREG, SCREG, \
|
---|
259 | SCREG, SCREG, SCREG, \
|
---|
260 |
|
---|
261 | #define ROVERLAP \
|
---|
262 | { -1 }, /* $zero */ \
|
---|
263 | { -1 }, /* $at */ \
|
---|
264 | { V0V1, -1 }, /* $v0 */ \
|
---|
265 | { V0V1, -1 }, /* $v1 */ \
|
---|
266 | { A0A1, -1 }, /* $a0 */ \
|
---|
267 | { A0A1, A1A2, -1 }, /* $a1 */ \
|
---|
268 | { A1A2, A2A3, -1 }, /* $a2 */ \
|
---|
269 | { A2A3, A3T0, -1 }, /* $a3 */ \
|
---|
270 | { A3T0, T0T1, -1 }, /* $t0 */ \
|
---|
271 | { T0T1, T1T2, -1 }, /* $t1 */ \
|
---|
272 | { T1T2, T2T3, -1 }, /* $t2 */ \
|
---|
273 | { T2T3, T3T4, -1 }, /* $t3 */ \
|
---|
274 | { T3T4, T4T5, -1 }, /* $t4 */ \
|
---|
275 | { T4T5, T5T6, -1 }, /* $t5 */ \
|
---|
276 | { T6T7, T7T8, -1 }, /* $t6 */ \
|
---|
277 | { T7T8, T8T9, -1 }, /* $t7 */ \
|
---|
278 | \
|
---|
279 | { S0S1, -1 }, /* $s0 */ \
|
---|
280 | { S0S1, S1S2, -1 }, /* $s1 */ \
|
---|
281 | { S1S2, S2S3, -1 }, /* $s2 */ \
|
---|
282 | { S2S3, S3S4, -1 }, /* $s3 */ \
|
---|
283 | { S3S4, S4S5, -1 }, /* $s4 */ \
|
---|
284 | { S4S5, S5S6, -1 }, /* $s5 */ \
|
---|
285 | { S5S6, S6S7, -1 }, /* $s6 */ \
|
---|
286 | { S6S7, -1 }, /* $s7 */ \
|
---|
287 | \
|
---|
288 | { T7T8, T8T9, -1 }, /* $t8 */ \
|
---|
289 | { T8T9, -1 }, /* $t9 */ \
|
---|
290 | \
|
---|
291 | { -1 }, /* $k0 */ \
|
---|
292 | { -1 }, /* $k1 */ \
|
---|
293 | { -1 }, /* $gp */ \
|
---|
294 | { -1 }, /* $sp */ \
|
---|
295 | { -1 }, /* $fp */ \
|
---|
296 | { -1 }, /* $ra */ \
|
---|
297 | \
|
---|
298 | { V0, V1, -1 }, /* $v0:$v1 */ \
|
---|
299 | \
|
---|
300 | { A0, A1, A1A2, -1 }, /* $a0:$a1 */ \
|
---|
301 | { A1, A2, A0A1, A2A3, -1 }, /* $a1:$a2 */ \
|
---|
302 | { A2, A3, A1A2, A3T0, -1 }, /* $a2:$a3 */ \
|
---|
303 | { A3, T0, A2A3, T0T1, -1 }, /* $a3:$t0 */ \
|
---|
304 | { T0, T1, A3T0, T1T2, -1 }, /* $t0:$t1 */ \
|
---|
305 | { T1, T2, T0T1, T2T3, -1 }, /* $t1:$t2 */ \
|
---|
306 | { T2, T3, T1T2, T3T4, -1 }, /* $t2:$t3 */ \
|
---|
307 | { T3, T4, T2T3, T4T5, -1 }, /* $t3:$t4 */ \
|
---|
308 | { T4, T5, T3T4, T5T6, -1 }, /* $t4:$t5 */ \
|
---|
309 | { T5, T6, T4T5, T6T7, -1 }, /* $t5:$t6 */ \
|
---|
310 | { T6, T7, T5T6, T7T8, -1 }, /* $t6:$t7 */ \
|
---|
311 | { T7, T8, T6T7, T8T9, -1 }, /* $t7:$t8 */ \
|
---|
312 | { T8, T9, T7T8, -1 }, /* $t8:$t9 */ \
|
---|
313 | \
|
---|
314 | { S0, S1, S1S2, -1 }, /* $s0:$s1 */ \
|
---|
315 | { S1, S2, S0S1, S2S3, -1 }, \
|
---|
316 | { S2, S3, S1S2, S3S4, -1 }, \
|
---|
317 | { S3, S4, S2S3, S4S5, -1 }, \
|
---|
318 | { S4, S5, S3S4, S5S6, -1 }, \
|
---|
319 | { S5, S6, S4S5, S6S7, -1 }, \
|
---|
320 | { S6, S7, S5S6, -1 }, \
|
---|
321 | \
|
---|
322 | { -1 }, { -1 }, { -1 }, { -1 }, \
|
---|
323 | { -1 }, { -1 }, { -1 }, { -1 }, \
|
---|
324 | { -1 }, { -1 }, { -1 }, \
|
---|
325 |
|
---|
326 | #define GCLASS(x) (x < 32 ? CLASSA : (x < 52 ? CLASSB : CLASSC))
|
---|
327 | #define PCLASS(p) (1 << gclass((p)->n_type))
|
---|
328 | #define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */
|
---|
329 | #define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */
|
---|
330 | #define ENCRD(x) (x) /* Encode dest reg in n_reg */
|
---|
331 |
|
---|
332 | int COLORMAP(int c, int *r);
|
---|
333 |
|
---|
334 | extern int bigendian;
|
---|
335 | extern int nargregs;
|
---|
336 |
|
---|
337 | #define SPCON (MAXSPECIAL+1) /* positive constant */
|
---|
338 |
|
---|
339 | #define TARGET_STDARGS
|
---|
340 | #define TARGET_BUILTINS \
|
---|
341 | { "__builtin_stdarg_start", mips_builtin_stdarg_start, 2 }, \
|
---|
342 | { "__builtin_va_arg", mips_builtin_va_arg, 2 }, \
|
---|
343 | { "__builtin_va_end", mips_builtin_va_end, 1 }, \
|
---|
344 | { "__builtin_va_copy", mips_builtin_va_copy, 2 },
|
---|
345 |
|
---|
346 | struct node;
|
---|
347 | struct node *mips_builtin_stdarg_start(struct node *f, struct node *a, unsigned int);
|
---|
348 | struct node *mips_builtin_va_arg(struct node *f, struct node *a, unsigned int);
|
---|
349 | struct node *mips_builtin_va_end(struct node *f, struct node *a, unsigned int);
|
---|
350 | struct node *mips_builtin_va_copy(struct node *f, struct node *a, unsigned int);
|
---|