Debian Codegraph @

arch/i86/macdefs.h

raw symbols SCIP
1 /* $Id: macdefs.h,v 1.9 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 * Machine-dependent defines for both passes.
31 */
32
33 /*
34 * Convert (multi-)character constant to integer.
35 */
36 #define makecc(val,i) lastcon = (lastcon<<8)|((val<<24)>>24);
37
38 #define ARGINIT 64 /* # bits above fp where arguments start */
39 #define AUTOINIT 0 /* # bits below fp where automatics start */
40
41 /*
42 * Storage space requirements
43 */
44 #define SZCHAR 8
45 #define SZBOOL 8
46 #define SZINT 16
47 #define SZFLOAT 32
48 #define SZDOUBLE 64
49 #define SZLDOUBLE 96
50 #define SZLONG 32
51 #define SZSHORT 16
52 #define SZLONGLONG 64 /* Doesn't work usefully yet */
53 #define SZPOINT(t) 16 /* FIXME: 32 for large model work */
54
55 /*
56 * Alignment constraints
57 */
58 #define ALCHAR 8
59 #define ALBOOL 8
60 #define ALINT 16
61 #define ALFLOAT 32
62 #define ALDOUBLE 32
63 #define ALLDOUBLE 32
64 #define ALLONG 16
65 #define ALLONGLONG 16
66 #define ALSHORT 16
67 #define ALPOINT 16
68 #undef ALSTRUCT /* Not defined if ELF ABI */
69 #define ALSTACK 16
70 #define ALMAX 128 /* not yet supported type */
71
72 /*
73 * Min/max values.
74 */
75 #define MIN_CHAR -128
76 #define MAX_CHAR 127
77 #define MAX_UCHAR 255
78 #define MIN_SHORT -32768
79 #define MAX_SHORT 32767
80 #define MAX_USHORT 65535
81 #define MIN_INT MIN_SHORT
82 #define MAX_INT MAX_SHORT
83 #define MAX_UNSIGNED MAX_USHORT
84 #define MIN_LONG (-0x7fffffff-1)
85 #define MAX_LONG 0x7fffffff
86 #define MAX_ULONG 0xffffffff
87 #define MIN_LONGLONG MIN_LONG
88 #define MAX_LONGLONG MAX_LONG
89 #define MAX_ULONGLONG MAX_ULONG
90
91 /* Default char is signed */
92 #undef CHAR_UNSIGNED
93 #define BOOL_TYPE UCHAR /* what used to store _Bool */
94 #undef UNALIGNED_ACCESS
95 /*
96 * Use large-enough types.
97 */
98 typedef long long CONSZ;
99 typedef unsigned long long U_CONSZ;
100 typedef long long OFFSZ;
101
102 #define CONFMT "%lld" /* format for printing constants */
103 #define LABFMT "L%d" /* format for printing labels */
104 #define STABLBL "LL%d" /* format for stab (debugging) labels */
105 #ifdef LANG_F77
106 #define BLANKCOMMON "_BLNK_"
107 #define MSKIREG (M(TYSHORT)|M(TYLONG))
108 #define TYIREG TYLONG
109 #define FSZLENG FSZLONG
110 #define AUTOREG BP
111 #define ARGREG BP
112 #define ARGOFFSET 4
113 #endif
114
115 #define STACK_DOWN /* stack grows negatively for automatics */
116
117 #undef FIELDOPS /* no bit-field instructions */
118 #define TARGET_ENDIAN TARGET_LE
119
120 #define FINDMOPS /* i86 has instructions that modifies memory */
121 #define CC_DIV_0 /* division by zero is safe in the compiler */
122
123 /* Definitions mostly used in pass2 */
124
125 #define BYTEOFF(x) ((x)&03)
126 #define wdal(k) (BYTEOFF(k)==0)
127
128 #define STOARG(p)
129 #define STOFARG(p)
130 #define STOSTARG(p)
131 #define genfcall(a,b) gencall(a,b)
132
133 /* FIXME: float sizes wrong at this point ? */
134 #define szty(t) (((t) == DOUBLE || (t) == FLOAT || \
135 (t) == LONG || t == ULONG || (t) == LONGLONG || (t) == ULONGLONG) ? 2 : (t) == LDOUBLE ? 3 : 1)
136
137 /*
138 * The x86 has a bunch of register classes, most of them interfering
139 * with each other. All registers are given a sequential number to
140 * identify it which must match rnames[] in local2.c.
141 * Class membership and overlaps are defined in the macros RSTATUS
142 * and ROVERLAP below.
143 *
144 * The classes used on x86 are:
145 * A - short and int regs
146 * B - char regs
147 * C - long and longlong regs
148 * D - floating point
149 */
150 #define AX 000 /* Scratch and return register */
151 #define DX 001 /* Scratch and secondary return register */
152 #define CX 002 /* Scratch (and shift count) register */
153 #define BX 003 /* GDT pointer or callee-saved temporary register */
154 #define SI 004 /* Callee-saved temporary register */
155 #define DI 005 /* Callee-saved temporary register */
156 #define BP 006 /* Frame pointer */
157 #define SP 007 /* Stack pointer */
158
159 #define AL 010
160 #define AH 011
161 #define DL 012
162 #define DH 013
163 #define CL 014
164 #define CH 015
165 #define BL 016
166 #define BH 017
167
168 #define AXDX 020
169 #define AXCX 021
170 #define AXBX 022
171 #define AXSI 023
172 #define AXDI 024
173 #define DXCX 025
174 #define DXBX 026
175 #define DXSI 027
176 #define DXDI 030
177 #define CXBX 031
178 #define CXSI 032
179 #define CXDI 033
180 #define BXSI 034
181 #define BXDI 035
182 #define SIDI 036
183
184 /* The 8 math registers in class D lacks names */
185
186 #define MAXREGS 047 /* 39 registers */
187
188 #define RSTATUS \
189 SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|PERMREG, \
190 SAREG|PERMREG, SAREG|PERMREG, 0, 0, \
191 SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, SBREG, \
192 SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, \
193 SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, SCREG, \
194 SDREG, SDREG, SDREG, SDREG, SDREG, SDREG, SDREG, SDREG,
195
196 #define ROVERLAP \
197 /* 8 basic registers */\
198 { AL, AH, AXDX, AXCX, AXBX, AXSI, AXDI, -1 },\
199 { DL, DH, AXDX, DXCX, DXBX, DXSI, DXDI, -1 },\
200 { CL, CH, AXCX, DXCX, CXBX, CXSI, CXDI, -1 },\
201 { BL, BH, AXBX, DXBX, CXBX, BXSI, BXDI, -1 },\
202 { AXSI, DXSI, CXSI, BXSI, SIDI, -1 },\
203 { AXDI, DXDI, CXDI, BXDI, SIDI, -1 },\
204 { -1 },\
205 { -1 },\
206 \
207 /* 8 char registers */\
208 { AX, AXDX, AXCX, AXBX, AXSI, AXDI, -1 },\
209 { AX, AXDX, AXCX, AXBX, AXSI, AXDI, -1 },\
210 { DX, AXDX, DXCX, DXBX, DXSI, DXDI, -1 },\
211 { DX, AXDX, DXCX, DXBX, DXSI, DXDI, -1 },\
212 { CX, AXCX, DXCX, CXBX, CXSI, CXDI, -1 },\
213 { CX, AXCX, DXCX, CXBX, CXSI, CXDI, -1 },\
214 { BX, AXBX, DXBX, CXBX, BXSI, BXDI, -1 },\
215 { BX, AXBX, DXBX, CXBX, BXSI, BXDI, -1 },\
216 \
217 /* 15 long emulating registers */\
218 { AX, AL, AH, DX, DL, DH, AXCX, AXBX, AXSI, /* axdx */\
219 AXDI, DXCX, DXBX, DXSI, DXDI, -1, },\
220 { AX, AL, AH, CX, CL, CH, AXDX, AXBX, AXSI, /* axcx */\
221 AXDI, DXCX, CXBX, CXSI, CXDI, -1 },\
222 { AX, AL, AH, BX, BL, BH, AXDX, AXCX, AXSI, /* axbx */\
223 AXDI, DXBX, CXBX, BXSI, BXDI, -1 },\
224 { AX, AL, AH, SI, AXDX, AXCX, AXBX, AXDI, /* axsi */\
225 DXSI, CXSI, BXSI, SIDI, -1 },\
226 { AX, AL, AH, DI, AXDX, AXCX, AXBX, AXSI, /* axdi */\
227 DXDI, CXDI, BXDI, SIDI, -1 },\
228 { DX, DL, DH, CX, CL, CH, AXDX, AXCX, DXBX, /* dxcx */\
229 DXSI, DXDI, CXBX, CXSI, CXDI, -1 },\
230 { DX, DL, DH, BX, BL, BH, AXDX, DXCX, DXSI, /* dxbx */\
231 DXDI, AXBX, CXBX, BXSI, BXDI, -1 },\
232 { DX, DL, DH, SI, AXDX, DXCX, DXBX, DXDI, /* dxsi */\
233 AXSI, CXSI, BXSI, SIDI, -1 },\
234 { DX, DL, DH, DI, AXDX, DXCX, DXBX, DXSI, /* dxdi */\
235 AXDI, CXDI, BXDI, SIDI, -1 },\
236 { CX, CL, CH, BX, BL, BH, AXCX, DXCX, CXSI, /* cxbx */\
237 CXDI, AXBX, DXBX, BXSI, BXDI, -1 },\
238 { CX, CL, CH, SI, AXCX, DXCX, CXBX, CXDI, /* cxsi */\
239 AXSI, DXSI, BXSI, SIDI, -1 },\
240 { CX, CL, CH, DI, AXCX, DXCX, CXBX, CXSI, /* cxdi */\
241 AXDI, DXDI, BXDI, SIDI, -1 },\
242 { BX, BL, BH, SI, AXBX, DXBX, CXBX, BXDI, /* bxsi */\
243 AXSI, DXSI, CXSI, SIDI, -1 },\
244 { BX, BL, BH, DI, AXBX, DXBX, CXBX, BXSI, /* bxdi */\
245 AXDI, DXDI, CXDI, SIDI, -1 },\
246 { SI, DI, AXSI, DXSI, CXSI, BXSI, /* sidi */\
247 AXDI, DXDI, CXDI, BXDI, -1 },\
248 \
249 /* The fp registers do not overlap with anything */\
250 { -1 },\
251 { -1 },\
252 { -1 },\
253 { -1 },\
254 { -1 },\
255 { -1 },\
256 { -1 },\
257 { -1 },
258
259
260 /* Return a register class based on the type of the node */
261 /* FIXME: <= UCHAR includes long ?? check */
262 #define PCLASS(p) (p->n_type <= UCHAR ? SBREG : \
263 (p->n_type == LONG || p->n_type == ULONG || p->n_type == LONGLONG || p->n_type == ULONGLONG ? SCREG : \
264 (p->n_type >= FLOAT && p->n_type <= LDOUBLE ? SDREG : SAREG)))
265
266 #define NUMCLASS 4 /* highest number of reg classes used */
267
268 int COLORMAP(int c, int *r);
269 #define GCLASS(x) (x < 8 ? CLASSA : x < 16 ? CLASSB : x < 31 ? CLASSC : CLASSD)
270 #define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */
271 #define ENCRD(x) (x) /* Encode dest reg in n_reg */
272 #define ENCRA1(x) ((x) << 6) /* A1 */
273 #define ENCRA2(x) ((x) << 12) /* A2 */
274 #define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */
275 /* XXX - return char in al? */
276 #define RETREG(x) (x == CHAR || x == UCHAR ? AL : \
277 x == LONG || x == ULONG || x == LONGLONG || x == ULONGLONG ? AXDX : \
278 x == FLOAT || x == DOUBLE || x == LDOUBLE ? 31 : AX)
279
280 #if 0
281 #define R2REGS 1 /* permit double indexing */
282 #endif
283
284 /* XXX - to die */
285 #define FPREG BP /* frame pointer */
286 #define STKREG SP /* stack pointer */
287
288 #define SHSTR (MAXSPECIAL+1) /* short struct */
289 #define SFUNCALL (MAXSPECIAL+2) /* struct assign after function call */
290 #define SPCON (MAXSPECIAL+3) /* positive nonnamed constant */
291
292 /*
293 * Specials that indicate the applicability of machine idioms.
294 */
295 #define SMIXOR (MAXSPECIAL+4)
296 #define SMILWXOR (MAXSPECIAL+5)
297 #define SMIHWXOR (MAXSPECIAL+6)
298 #define STWO (MAXSPECIAL+7) /* exactly two */
299 #define SMTWO (MAXSPECIAL+8) /* exactly minus two */
300
301 /*
302 * i86-specific symbol table flags.
303 */
304 #define SSECTION SLOCAL1
305 #define SSTDCALL SLOCAL2
306 #define SDLLINDIRECT SLOCAL3
307
308 /*
309 * i86-specific interpass stuff.
310 */
311
312 #define TARGET_IPP_MEMBERS \
313 int ipp_argstacksize;
314
315 #define HAVE_WEAKREF
316 #define TARGET_FLT_EVAL_METHOD 2 /* all as long double */
317
318 /*
319 * Extended assembler macros.
320 */
321 void targarg(char *w, void *arg);
322 #define XASM_TARGARG(w, ary) \
323 (w[1] == 'b' || w[1] == 'h' || w[1] == 'w' || w[1] == 'k' ? \
324 w++, targarg(w, ary), 1 : 0)
325 int numconv(void *ip, void *p, void *q);
326 #define XASM_NUMCONV(ip, p, q) numconv(ip, p, q)
327 int xasmconstregs(char *);
328 #define XASMCONSTREGS(x) xasmconstregs(x)
329 #define MYSETXARG if (XASMVAL(cw) == 'q') { \
330 c = 'r'; addalledges(&ablock[SI]); addalledges(&ablock[DI]); }
331
332 /* target specific attributes */
333 #define ATTR_MI_TARGET ATTR_I86_FPPOP
334
335 /* floating point definitions */
336 #define USE_IEEEFP_32
337 #define FLT_PREFIX IEEEFP_32
338 #define USE_IEEEFP_64
339 #define DBL_PREFIX IEEEFP_64
340 #define USE_IEEEFP_X80
341 #define LDBL_PREFIX IEEEFP_X80
342