Debian Codegraph @

arch/mips/macdefs.h

raw symbols SCIP
1 /* $Id: macdefs.h,v 1.27 2021/10/08 15:59:06 ragge Exp $ */
2 /*
3 * Copyright (c) 2003 Anders Magnusson ([email protected]).
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 ([email protected]) and
31 * Simon Olsson ([email protected]) 2005.
32 */
33
34 /*
35 * Machine-dependent defines for both passes.
36 */
37
38 #if defined(os_netbsd) || defined(os_litebsd)
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 (-0x7fffffff-1)
92 #define MAX_INT 0x7fffffff
93 #define MAX_UNSIGNED 0xffffffffU
94 #define MIN_LONG MIN_INT
95 #define MAX_LONG 0x7fffffffL
96 #define MAX_ULONG 0xffffffffUL
97 #define MIN_LONGLONG (-0x7fffffffffffffffLL-1)
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 STACK_DOWN /* stack grows negatively for automatics */
121
122 #undef FIELDOPS /* no bit-field instructions */
123 #define TARGET_ENDIAN TARGET_LE
124 #define MYALIGN
125
126 /* Definitions mostly used in pass2 */
127
128 #define BYTEOFF(x) ((x)&03)
129
130 #define szty(t) (((t) == DOUBLE || (t) == LDOUBLE || \
131 DEUNSIGN(t) == LONGLONG) ? 2 : 1)
132
133 /*
134 * Register names. These must match rnames[] and rstatus[] in local2.c.
135 */
136 #define ZERO 0
137 #define AT 1
138 #define V0 2
139 #define V1 3
140 #define A0 4
141 #define A1 5
142 #define A2 6
143 #define A3 7
144 #define A4 8
145 #define A5 9
146 #define A6 10
147 #define A7 11
148 #if defined(MIPS_N32) || defined(MIPS_N64)
149 #define T0 12
150 #define T1 13
151 #define T2 14
152 #define T3 15
153 #else
154 #define T0 8
155 #define T1 9
156 #define T2 10
157 #define T3 11
158 #endif
159 #define T4 12
160 #define T5 13
161 #define T6 14
162 #define T7 15
163 #define S0 16
164 #define S1 17
165 #define S2 18
166 #define S3 19
167 #define S4 20
168 #define S5 21
169 #define S6 22
170 #define S7 23
171 #define T8 24
172 #define T9 25
173 #define K0 26
174 #define K1 27
175 #define GP 28
176 #define SP 29
177 #define FP 30
178 #define RA 31
179
180 #define V0V1 32
181 #define A0A1 33
182 #define A1A2 34
183 #define A2A3 35
184
185 /* we just use o32 naming here, but it works ok for n32/n64 */
186 #define A3T0 36
187 #define T0T1 37
188 #define T1T2 38
189 #define T2T3 39
190 #define T3T4 40
191 #define T4T5 41
192 #define T5T6 42
193 #define T6T7 43
194 #define T7T8 44
195
196 #define T8T9 45
197 #define S0S1 46
198 #define S1S2 47
199 #define S2S3 48
200 #define S3S4 49
201 #define S4S5 50
202 #define S5S6 51
203 #define S6S7 52
204
205 #define F0 53
206 #define F2 54
207 #define F4 55
208 #define F6 56
209 #define F8 57
210 #define F10 58
211 #define F12 59
212 #define F14 60
213 #define F16 61
214 #define F18 62
215 #define F20 63
216 /* and the rest for later */
217 #define F22 64
218 #define F24 65
219 #define F26 66
220 #define F28 67
221 #define F30 68
222
223 #define MAXREGS 64
224 #define NUMCLASS 3
225
226 #define RETREG(x) (DEUNSIGN(x) == LONGLONG ? V0V1 : \
227 (x) == DOUBLE || (x) == LDOUBLE || (x) == FLOAT ? \
228 F0 : V0)
229 #define FPREG FP /* frame pointer */
230
231 #define MIPS_N32_NARGREGS 8
232 #define MIPS_O32_NARGREGS 4
233
234 #define RSTATUS \
235 0, 0, \
236 SAREG|TEMPREG, SAREG|TEMPREG, \
237 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
238 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
239 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
240 SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \
241 SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \
242 SAREG|TEMPREG, SAREG|TEMPREG, \
243 0, 0, \
244 0, 0, 0, 0, \
245 \
246 SBREG|TEMPREG, \
247 SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, \
248 SBREG|TEMPREG, \
249 SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, \
250 SBREG|TEMPREG, SBREG|TEMPREG, \
251 SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, \
252 SBREG, SBREG, SBREG, SBREG, \
253 SBREG, SBREG, SBREG, \
254 SCREG, SCREG, SCREG, SCREG, \
255 SCREG, SCREG, SCREG, SCREG, \
256 SCREG, SCREG, SCREG, \
257
258 #define ROVERLAP \
259 { -1 }, /* $zero */ \
260 { -1 }, /* $at */ \
261 { V0V1, -1 }, /* $v0 */ \
262 { V0V1, -1 }, /* $v1 */ \
263 { A0A1, -1 }, /* $a0 */ \
264 { A0A1, A1A2, -1 }, /* $a1 */ \
265 { A1A2, A2A3, -1 }, /* $a2 */ \
266 { A2A3, A3T0, -1 }, /* $a3 */ \
267 { A3T0, T0T1, -1 }, /* $t0 */ \
268 { T0T1, T1T2, -1 }, /* $t1 */ \
269 { T1T2, T2T3, -1 }, /* $t2 */ \
270 { T2T3, T3T4, -1 }, /* $t3 */ \
271 { T3T4, T4T5, -1 }, /* $t4 */ \
272 { T4T5, T5T6, -1 }, /* $t5 */ \
273 { T6T7, T7T8, -1 }, /* $t6 */ \
274 { T7T8, T8T9, -1 }, /* $t7 */ \
275 \
276 { S0S1, -1 }, /* $s0 */ \
277 { S0S1, S1S2, -1 }, /* $s1 */ \
278 { S1S2, S2S3, -1 }, /* $s2 */ \
279 { S2S3, S3S4, -1 }, /* $s3 */ \
280 { S3S4, S4S5, -1 }, /* $s4 */ \
281 { S4S5, S5S6, -1 }, /* $s5 */ \
282 { S5S6, S6S7, -1 }, /* $s6 */ \
283 { S6S7, -1 }, /* $s7 */ \
284 \
285 { T7T8, T8T9, -1 }, /* $t8 */ \
286 { T8T9, -1 }, /* $t9 */ \
287 \
288 { -1 }, /* $k0 */ \
289 { -1 }, /* $k1 */ \
290 { -1 }, /* $gp */ \
291 { -1 }, /* $sp */ \
292 { -1 }, /* $fp */ \
293 { -1 }, /* $ra */ \
294 \
295 { V0, V1, -1 }, /* $v0:$v1 */ \
296 \
297 { A0, A1, A1A2, -1 }, /* $a0:$a1 */ \
298 { A1, A2, A0A1, A2A3, -1 }, /* $a1:$a2 */ \
299 { A2, A3, A1A2, A3T0, -1 }, /* $a2:$a3 */ \
300 { A3, T0, A2A3, T0T1, -1 }, /* $a3:$t0 */ \
301 { T0, T1, A3T0, T1T2, -1 }, /* $t0:$t1 */ \
302 { T1, T2, T0T1, T2T3, -1 }, /* $t1:$t2 */ \
303 { T2, T3, T1T2, T3T4, -1 }, /* $t2:$t3 */ \
304 { T3, T4, T2T3, T4T5, -1 }, /* $t3:$t4 */ \
305 { T4, T5, T3T4, T5T6, -1 }, /* $t4:$t5 */ \
306 { T5, T6, T4T5, T6T7, -1 }, /* $t5:$t6 */ \
307 { T6, T7, T5T6, T7T8, -1 }, /* $t6:$t7 */ \
308 { T7, T8, T6T7, T8T9, -1 }, /* $t7:$t8 */ \
309 { T8, T9, T7T8, -1 }, /* $t8:$t9 */ \
310 \
311 { S0, S1, S1S2, -1 }, /* $s0:$s1 */ \
312 { S1, S2, S0S1, S2S3, -1 }, \
313 { S2, S3, S1S2, S3S4, -1 }, \
314 { S3, S4, S2S3, S4S5, -1 }, \
315 { S4, S5, S3S4, S5S6, -1 }, \
316 { S5, S6, S4S5, S6S7, -1 }, \
317 { S6, S7, S5S6, -1 }, \
318 \
319 { -1 }, { -1 }, { -1 }, { -1 }, \
320 { -1 }, { -1 }, { -1 }, { -1 }, \
321 { -1 }, { -1 }, { -1 }, \
322
323 #define GCLASS(x) (x < 32 ? CLASSA : (x < 52 ? CLASSB : CLASSC))
324 #define PCLASS(p) (1 << gclass((p)->n_type))
325 #define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */
326 #define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */
327 #define ENCRD(x) (x) /* Encode dest reg in n_reg */
328
329 int COLORMAP(int c, int *r);
330
331 extern int bigendian;
332 extern int nargregs;
333
334 #define SPCON (MAXSPECIAL+1) /* positive constant */
335
336 #define TARGET_STDARGS
337 #define TARGET_BUILTINS \
338 { "__builtin_stdarg_start", mips_builtin_stdarg_start, \
339 0, 2, 0, VOID }, \
340 { "__builtin_va_start", mips_builtin_stdarg_start, \
341 0, 2, 0, VOID }, \
342 { "__builtin_va_arg", mips_builtin_va_arg, BTNORVAL|BTNOPROTO, \
343 2, 0, 0 }, \
344 { "__builtin_va_end", mips_builtin_va_end, 0, 1, 0, VOID }, \
345 { "__builtin_va_copy", mips_builtin_va_copy, 0, 2, 0, VOID },
346
347 #ifdef LANG_CXX
348 #define P1ND struct node
349 #else
350 #define P1ND struct p1node
351 #endif
352 struct node;
353 struct bitable;
354 P1ND *mips_builtin_stdarg_start(const struct bitable *, P1ND *a);
355 P1ND *mips_builtin_va_arg(const struct bitable *, P1ND *a);
356 P1ND *mips_builtin_va_end(const struct bitable *, P1ND *a);
357 P1ND *mips_builtin_va_copy(const struct bitable *, P1ND *a);
358 #undef P1ND
359
360 /* floating point definitions */
361 #define USE_IEEEFP_32
362 #define FLT_PREFIX IEEEFP_32
363 #define USE_IEEEFP_64
364 #define DBL_PREFIX IEEEFP_64
365 #define LDBL_PREFIX IEEEFP_64
366 #define DEFAULT_FPI_DEFS { &fpi_binary32, &fpi_binary64, &fpi_binary64 }