Debian Codegraph @

arch/mips64/macdefs.h

raw symbols SCIP
1 /* $Id: macdefs.h,v 1.4 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 * Extended to MIPS64 by Brian Callahan <[email protected]> 2016.
34 */
35
36 /*
37 * Machine-dependent defines for both passes.
38 */
39
40 #if defined(os_netbsd) || defined(os_litebsd) || defined(os_openbsd)
41 #define USE_GAS
42 #endif
43
44 /*
45 * Convert (multi-)character constant to integer.
46 * Assume: If only one value; store at left side (char size), otherwise
47 * treat it as an integer.
48 */
49 #define makecc(val,i) lastcon = (lastcon<<8)|((val<<24)>>24);
50
51 #define ARGINIT (32*8) /* # bits above fp where arguments start */
52 #define AUTOINIT (0) /* # bits below fp where automatics start */
53
54 /*
55 * Storage space requirements
56 */
57 #define SZCHAR 8
58 #define SZBOOL 32
59 #define SZINT 32
60 #define SZFLOAT 32
61 #define SZDOUBLE 64
62 #define SZLDOUBLE 64
63 #define SZLONG 64
64 #define SZSHORT 16
65 #define SZLONGLONG 64
66 #define SZPOINT(t) 64
67
68 /*
69 * Alignment constraints
70 */
71 #define ALCHAR 8
72 #define ALBOOL 64
73 #define ALINT 64
74 #define ALFLOAT 32
75 #define ALDOUBLE 64
76 #define ALLDOUBLE 64
77 #define ALLONG 64
78 #define ALLONGLONG 64
79 #define ALSHORT 16
80 #define ALPOINT 64
81 #define ALSTRUCT 64
82 #define ALSTACK 64
83
84 /*
85 * Min/max values.
86 */
87 #define MIN_CHAR -128
88 #define MAX_CHAR 127
89 #define MAX_UCHAR 255
90 #define MIN_SHORT -32768
91 #define MAX_SHORT 32767
92 #define MAX_USHORT 65535
93 #define MIN_INT (-0x7fffffff-1)
94 #define MAX_INT 0x7fffffff
95 #define MAX_UNSIGNED 0xffffffffU
96 #define MIN_LONG MIN_LONGLONG
97 #define MAX_LONG MAX_LONGLONG
98 #define MAX_ULONG MAX_ULONGLONG
99 #define MIN_LONGLONG (-0x7fffffffffffffffLL-1)
100 #define MAX_LONGLONG 0x7fffffffffffffffLL
101 #define MAX_ULONGLONG 0xffffffffffffffffULL
102
103 #undef CHAR_UNSIGNED
104 #define BOOL_TYPE INT
105
106 /*
107 * Use large-enough types.
108 */
109 typedef long long CONSZ;
110 typedef unsigned long long U_CONSZ;
111 typedef long long OFFSZ;
112
113 #define CONFMT "%lld" /* format for printing constants */
114 #ifdef USE_GAS
115 #define LABFMT "$L%d" /* format for printing labels */
116 #define STABLBL "$LL%d" /* format for stab (debugging) labels */
117 #else
118 #define LABFMT "L%d" /* format for printing labels */
119 #define STABLBL "LL%d" /* format for stab (debugging) labels */
120 #endif
121
122 #define STACK_DOWN /* stack grows negatively for automatics */
123
124 #undef FIELDOPS /* no bit-field instructions */
125 #define TARGET_ENDIAN TARGET_LE
126 #define MYALIGN
127
128 /* Definitions mostly used in pass2 */
129
130 #define BYTEOFF(x) ((x)&03)
131
132 #define szty(t) (((t) == DOUBLE || (t) == LDOUBLE || \
133 DEUNSIGN(t) == LONG || DEUNSIGN(t) == LONGLONG) ? 2 : 1)
134
135 /*
136 * Register names. These must match rnames[] and rstatus[] in local2.c.
137 */
138 #define ZERO 0
139 #define AT 1
140 #define V0 2
141 #define V1 3
142 #define A0 4
143 #define A1 5
144 #define A2 6
145 #define A3 7
146 #define A4 8
147 #define A5 9
148 #define A6 10
149 #define A7 11
150 #define T4 12
151 #define T5 13
152 #define T6 14
153 #define T7 15
154 #define S0 16
155 #define S1 17
156 #define S2 18
157 #define S3 19
158 #define S4 20
159 #define S5 21
160 #define S6 22
161 #define S7 23
162 #define T8 24
163 #define T9 25
164 #define K0 26
165 #define K1 27
166 #define GP 28
167 #define SP 29
168 #define FP 30
169 #define RA 31
170
171 #define V0V1 32
172 #define A0A1 33
173 #define A1A2 34
174 #define A2A3 35
175
176 /* we just use o32 naming here, but it works ok for n32/n64 */
177 #define A3T0 36
178 #define T0T1 37
179 #define T1T2 38
180 #define T2T3 39
181 #define T3T4 40
182 #define T4T5 41
183 #define T5T6 42
184 #define T6T7 43
185 #define T7T8 44
186
187 #define T8T9 45
188 #define S0S1 46
189 #define S1S2 47
190 #define S2S3 48
191 #define S3S4 49
192 #define S4S5 50
193 #define S5S6 51
194 #define S6S7 52
195
196 #define F0 53
197 #define F2 54
198 #define F4 55
199 #define F6 56
200 #define F8 57
201 #define F10 58
202 #define F12 59
203 #define F14 60
204 #define F16 61
205 #define F18 62
206 #define F20 63
207 /* and the rest for later */
208 #define F22 64
209 #define F24 65
210 #define F26 66
211 #define F28 67
212 #define F30 68
213
214 #define MAXREGS 64
215 #define NUMCLASS 3
216
217 #define RETREG(x) ((DEUNSIGN(x) == LONG || DEUNSIGN(x) == LONGLONG) ? V0V1 : \
218 (x) == DOUBLE || (x) == LDOUBLE || (x) == FLOAT ? \
219 F0 : V0)
220 #define FPREG FP /* frame pointer */
221
222 #define MIPS_N64_NARGREGS 8
223
224 #define RSTATUS \
225 0, 0, \
226 SAREG|TEMPREG, SAREG|TEMPREG, \
227 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
228 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
229 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, \
230 SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \
231 SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, \
232 SAREG|TEMPREG, SAREG|TEMPREG, \
233 0, 0, \
234 0, 0, 0, 0, \
235 \
236 SBREG|TEMPREG, \
237 SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, \
238 SBREG|TEMPREG, \
239 SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, \
240 SBREG|TEMPREG, SBREG|TEMPREG, \
241 SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, \
242 SBREG, SBREG, SBREG, SBREG, \
243 SBREG, SBREG, SBREG, \
244 SCREG, SCREG, SCREG, SCREG, \
245 SCREG, SCREG, SCREG, SCREG, \
246 SCREG, SCREG, SCREG, \
247
248 #define ROVERLAP \
249 { -1 }, /* $zero */ \
250 { -1 }, /* $at */ \
251 { V0V1, -1 }, /* $v0 */ \
252 { V0V1, -1 }, /* $v1 */ \
253 { A0A1, -1 }, /* $a0 */ \
254 { A0A1, A1A2, -1 }, /* $a1 */ \
255 { A1A2, A2A3, -1 }, /* $a2 */ \
256 { A2A3, A3T0, -1 }, /* $a3 */ \
257 { A3T0, T0T1, -1 }, /* $a4 */ \
258 { T0T1, T1T2, -1 }, /* $a5 */ \
259 { T1T2, T2T3, -1 }, /* $a6 */ \
260 { T2T3, T3T4, -1 }, /* $a7 */ \
261 { T3T4, T4T5, -1 }, /* $t4 */ \
262 { T4T5, T5T6, -1 }, /* $t5 */ \
263 { T6T7, T7T8, -1 }, /* $t6 */ \
264 { T7T8, T8T9, -1 }, /* $t7 */ \
265 \
266 { S0S1, -1 }, /* $s0 */ \
267 { S0S1, S1S2, -1 }, /* $s1 */ \
268 { S1S2, S2S3, -1 }, /* $s2 */ \
269 { S2S3, S3S4, -1 }, /* $s3 */ \
270 { S3S4, S4S5, -1 }, /* $s4 */ \
271 { S4S5, S5S6, -1 }, /* $s5 */ \
272 { S5S6, S6S7, -1 }, /* $s6 */ \
273 { S6S7, -1 }, /* $s7 */ \
274 \
275 { T7T8, T8T9, -1 }, /* $t8 */ \
276 { T8T9, -1 }, /* $t9 */ \
277 \
278 { -1 }, /* $k0 */ \
279 { -1 }, /* $k1 */ \
280 { -1 }, /* $gp */ \
281 { -1 }, /* $sp */ \
282 { -1 }, /* $fp */ \
283 { -1 }, /* $ra */ \
284 \
285 { V0, V1, -1 }, /* $v0:$v1 */ \
286 \
287 { A0, A1, A1A2, -1 }, /* $a0:$a1 */ \
288 { A1, A2, A0A1, A2A3, -1 }, /* $a1:$a2 */ \
289 { A2, A3, A1A2, A3T0, -1 }, /* $a2:$a3 */ \
290 { A3, A4, A2A3, T0T1, -1 }, /* $a3:$t0 */ \
291 { A4, A5, A3T0, T1T2, -1 }, /* $t0:$t1 */ \
292 { A5, A6, T0T1, T2T3, -1 }, /* $t1:$t2 */ \
293 { A6, A7, T1T2, T3T4, -1 }, /* $t2:$t3 */ \
294 { A7, T4, T2T3, T4T5, -1 }, /* $t3:$t4 */ \
295 { T4, T5, T3T4, T5T6, -1 }, /* $t4:$t5 */ \
296 { T5, T6, T4T5, T6T7, -1 }, /* $t5:$t6 */ \
297 { T6, T7, T5T6, T7T8, -1 }, /* $t6:$t7 */ \
298 { T7, T8, T6T7, T8T9, -1 }, /* $t7:$t8 */ \
299 { T8, T9, T7T8, -1 }, /* $t8:$t9 */ \
300 \
301 { S0, S1, S1S2, -1 }, /* $s0:$s1 */ \
302 { S1, S2, S0S1, S2S3, -1 }, \
303 { S2, S3, S1S2, S3S4, -1 }, \
304 { S3, S4, S2S3, S4S5, -1 }, \
305 { S4, S5, S3S4, S5S6, -1 }, \
306 { S5, S6, S4S5, S6S7, -1 }, \
307 { S6, S7, S5S6, -1 }, \
308 \
309 { -1 }, { -1 }, { -1 }, { -1 }, \
310 { -1 }, { -1 }, { -1 }, { -1 }, \
311 { -1 }, { -1 }, { -1 }, \
312
313 #define GCLASS(x) (x < 32 ? CLASSA : (x < 52 ? CLASSB : CLASSC))
314 #define PCLASS(p) (1 << gclass((p)->n_type))
315 #define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */
316 #define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */
317 #define ENCRD(x) (x) /* Encode dest reg in n_reg */
318
319 int COLORMAP(int c, int *r);
320
321 extern int bigendian;
322 extern int nargregs;
323
324 #define SPCON (MAXSPECIAL+1) /* positive constant */
325
326 #define TARGET_STDARGS
327 #define TARGET_BUILTINS \
328 { "__builtin_stdarg_start", mips64_builtin_stdarg_start, \
329 0, 2, 0, VOID }, \
330 { "__builtin_va_start", mips64_builtin_stdarg_start, \
331 0, 2, 0, VOID }, \
332 { "__builtin_va_arg", mips64_builtin_va_arg, BTNORVAL|BTNOPROTO, \
333 2, 0, 0 }, \
334 { "__builtin_va_end", mips64_builtin_va_end, 0, 1, 0, VOID }, \
335 { "__builtin_va_copy", mips64_builtin_va_copy, 0, 2, 0, VOID },
336
337 #ifdef LANG_CXX
338 #define P1ND struct node
339 #else
340 #define P1ND struct p1node
341 #endif
342 struct node;
343 struct bitable;
344 P1ND *mips64_builtin_stdarg_start(const struct bitable *, P1ND *a);
345 P1ND *mips64_builtin_va_arg(const struct bitable *, P1ND *a);
346 P1ND *mips64_builtin_va_end(const struct bitable *, P1ND *a);
347 P1ND *mips64_builtin_va_copy(const struct bitable *, P1ND *a);
348 #undef P1ND
349
350 /* floating point definitions */
351 #define USE_IEEEFP_32
352 #define FLT_PREFIX IEEEFP_32
353 #define USE_IEEEFP_64
354 #define DBL_PREFIX IEEEFP_64
355 #define LDBL_PREFIX IEEEFP_64
356
357 #define DEFAULT_FPI_DEFS { &fpi_binary32, &fpi_binary64, &fpi_binary64 }