source: mainline/uspace/app/pcc/arch/powerpc/macdefs.h@ a837544

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since a837544 was a7de7182, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 14 years ago

Added pcc source tree (contents of pcc-1.0.0.tgz)

  • Property mode set to 100644
File size: 11.3 KB
RevLine 
[a7de7182]1/* $Id: macdefs.h,v 1.11 2010/11/26 17:06:31 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 * 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/*
39 * Storage space requirements
40 */
41#define SZCHAR 8
42#define SZBOOL 32
43#define SZINT 32
44#define SZFLOAT 32
45#define SZDOUBLE 64
46#ifdef ELFABI
47#define SZLDOUBLE 96
48#else
49#define SZLDOUBLE 128
50#endif
51#define SZLONG 32
52#define SZSHORT 16
53#define SZLONGLONG 64
54#define SZPOINT(t) 32
55
56/*
57 * Alignment constraints
58 */
59#define ALCHAR 8
60#define ALBOOL 32
61#define ALINT 32
62#define ALFLOAT 32
63#define ALDOUBLE 32
64#ifdef ELFABI
65#define ALLDOUBLE 32
66#else
67#define ALLDOUBLE 128
68#endif
69#define ALLONG 32
70#ifdef ELFABI
71#define ALLONGLONG 64
72#else
73#define ALLONGLONG 32
74#endif
75#define ALSHORT 16
76#define ALPOINT 32
77#define ALSTRUCT 32
78#define ALSTACK (16*SZCHAR)
79
80/*
81 * Min/max values.
82 */
83#define MIN_CHAR -128
84#define MAX_CHAR 127
85#define MAX_UCHAR 255
86#define MIN_SHORT -32768
87#define MAX_SHORT 32767
88#define MAX_USHORT 65535
89#define MIN_INT -1
90#define MAX_INT 0x7fffffff
91#define MAX_UNSIGNED 0xffffffff
92#define MIN_LONG MIN_INT
93#define MAX_LONG MAX_INT
94#define MAX_ULONG MAX_UNSIGNED
95#define MIN_LONGLONG 0x8000000000000000LL
96#define MAX_LONGLONG 0x7fffffffffffffffLL
97#define MAX_ULONGLONG 0xffffffffffffffffULL
98
99#define CHAR_UNSIGNED
100#define BOOL_TYPE INT /* what used to store _Bool */
101
102/*
103 * Use large-enough types.
104 */
105typedef long long CONSZ;
106typedef unsigned long long U_CONSZ;
107typedef long long OFFSZ;
108
109#define CONFMT "%lld" /* format for printing constants */
110#if defined(ELFABI)
111#define LABFMT ".L%d" /* format for printing labels */
112#define REGPREFIX "%" /* format for printing registers */
113#elif defined(MACHOABI)
114#define LABFMT "L%d" /* format for printing labels */
115#define REGPREFIX
116#else
117#error undefined ABI
118#endif
119#define STABLBL "LL%d" /* format for stab (debugging) labels */
120
121#ifdef MACHOABI
122#define STAB_LINE_ABSOLUTE /* S_LINE fields use absolute addresses */
123#endif
124
125#undef FIELDOPS /* no bit-field instructions */
126
127#define ENUMSIZE(high,low) INT /* enums are always stored in full int */
128
129/* Definitions mostly used in pass2 */
130
131#define BYTEOFF(x) ((x)&03)
132#define BITOOR(x) (x) /* bit offset to oreg offset XXX die! */
133
134#define szty(t) (((t) == DOUBLE || (t) == LDOUBLE || \
135 DEUNSIGN(t) == LONGLONG) ? 2 : 1)
136
137/*
138 * The PPC register definition are taken from apple docs.
139 *
140 * The classes used are:
141 * A - general registers
142 * B - 64-bit register pairs
143 * C - floating-point registers
144 */
145
146#define R0 0 /* scratch register */
147#define R1 1 /* stack base pointer */
148#define R2 2
149#define R3 3 /* return register / argument 0 */
150#define R4 4 /* return register (for longlong) / argument 1 */
151#define R5 5 /* scratch register / argument 2 */
152#define R6 6 /* scratch register / argument 3 */
153#define R7 7 /* scratch register / argument 4 */
154#define R8 8 /* scratch register / argument 5 */
155#define R9 9 /* scratch register / argument 6 */
156#define R10 10 /* scratch register / argument 7 */
157#define R11 11 /* scratch register */
158#define R12 12 /* scratch register */
159#define R13 13
160#define R14 14
161#define R15 15
162#define R16 16
163#define R17 17
164#define R18 18
165#define R19 19
166#define R20 20
167#define R21 21
168#define R22 22
169#define R23 23
170#define R24 24
171#define R25 25
172#define R26 26
173#define R27 27
174#define R28 28
175#define R29 29
176#define R30 30
177#define R31 31
178
179#define R3R4 32
180#define R4R5 33
181#define R5R6 34
182#define R6R7 35
183#define R7R8 36
184#define R8R9 37
185#define R9R10 38
186#define R14R15 39
187#define R16R17 40
188#define R18R19 41
189#define R20R21 42
190#define R22R23 43
191#define R24R25 44
192#define R26R27 45
193#define R28R29 46
194#define R30R31 47
195
196#define F0 48 /* scratch register */
197#define F1 49 /* return value 0 / argument 0 */
198#define F2 50 /* return value 1 / argument 1 */
199#define F3 51 /* return value 2 / argument 2 */
200#define F4 52 /* return value 3 / argument 3 */
201#define F5 53 /* argument 4 */
202#define F6 54 /* argument 5 */
203#define F7 55 /* argument 6 */
204#define F8 56 /* argument 7 */
205#define F9 57 /* argument 8 */
206#define F10 58 /* argument 9 */
207#define F11 59 /* argument 10 */
208#define F12 60 /* argument 11 */
209#define F13 61 /* argument 12 */
210#define F14 62
211#define F15 63
212#define F16 64
213#define F17 65
214#define F18 66
215#define F19 67
216#define F20 68
217#define F21 69
218#define F22 70
219#define F23 71
220#define F24 72
221#define F25 73
222#define F26 74
223#define F27 75
224#define F28 76
225#define F29 77
226#define F30 78
227#define F31 79
228
229#define NUMCLASS 3
230#define MAXREGS 64 /* XXX cannot have more than 64 */
231
232#define RSTATUS \
233 0, /* R0 */ \
234 0, /* R1 */ \
235 SAREG|TEMPREG, /* R2 */ \
236 SAREG|TEMPREG, /* R3 */ \
237 SAREG|TEMPREG, /* R4 */ \
238 SAREG|TEMPREG, /* R5 */ \
239 SAREG|TEMPREG, /* R6 */ \
240 SAREG|TEMPREG, /* R7 */ \
241 SAREG|TEMPREG, /* R8 */ \
242 SAREG|TEMPREG, /* R9 */ \
243 SAREG|TEMPREG, /* R10 */ \
244 SAREG|TEMPREG, /* R11 */ \
245 SAREG|TEMPREG, /* R12 */ \
246 SAREG, /* R13 */ \
247 SAREG, /* R14 */ \
248 SAREG, /* R15 */ \
249 SAREG, /* R16 */ \
250 SAREG, /* R17 */ \
251 SAREG, /* R18 */ \
252 SAREG, /* R19 */ \
253 SAREG, /* R20 */ \
254 SAREG, /* R21 */ \
255 SAREG, /* R22 */ \
256 SAREG, /* R23 */ \
257 SAREG, /* R24 */ \
258 SAREG, /* R25 */ \
259 SAREG, /* R26 */ \
260 SAREG, /* R27 */ \
261 SAREG, /* R28 */ \
262 SAREG, /* R29 */ \
263 SAREG, /* R30 */ \
264 SAREG, /* R31 */ \
265 \
266 SBREG|TEMPREG, /* R3R4 */ \
267 SBREG|TEMPREG, /* R4R5 */ \
268 SBREG|TEMPREG, /* R5R6 */ \
269 SBREG|TEMPREG, /* R6R7 */ \
270 SBREG|TEMPREG, /* R7R8 */ \
271 SBREG|TEMPREG, /* R8R9 */ \
272 SBREG|TEMPREG, /* R9R10 */ \
273 \
274 SBREG, /* R14R15 */ \
275 SBREG, /* R16R17 */ \
276 SBREG, /* R18R19 */ \
277 SBREG, /* R20R21 */ \
278 SBREG, /* R22R23 */ \
279 SBREG, /* R24R25 */ \
280 SBREG, /* R26R2k */ \
281 SBREG, /* R28R29 */ \
282 SBREG, /* R30R31 */ \
283 \
284 SCREG|TEMPREG, /* F0 */ \
285 SCREG|TEMPREG, /* F1 */ \
286 SCREG|TEMPREG, /* F2 */ \
287 SCREG|TEMPREG, /* F3 */ \
288 SCREG|TEMPREG, /* F4 */ \
289 SCREG|TEMPREG, /* F5 */ \
290 SCREG|TEMPREG, /* F6 */ \
291 SCREG|TEMPREG, /* F7 */ \
292 SCREG|TEMPREG, /* F8 */ \
293 SCREG|TEMPREG, /* F9 */ \
294 SCREG|TEMPREG, /* F10 */ \
295 SCREG|TEMPREG, /* F11 */ \
296 SCREG|TEMPREG, /* F12 */ \
297 SCREG|TEMPREG, /* F13 */ \
298 SCREG, /* F14 */ \
299 SCREG, /* F15 */ \
300
301#define ROVERLAP \
302 { -1 }, { -1 }, { -1 }, \
303 { R3R4, -1 }, { R3R4, R4R5, -1 }, \
304 { R4R5, R5R6, -1 }, { R5R6, R6R7, -1 }, \
305 { R6R7, R7R8, -1 }, { R7R8, R8R9, -1 }, \
306 { R8R9, R9R10, -1 }, { R9R10, -1 }, \
307 { -1 }, { -1 }, { -1 }, \
308 { R14R15, -1 }, { R14R15, -1 }, \
309 { R16R17, -1 }, { R16R17, -1 }, \
310 { R18R19, -1 }, { R18R19, -1 }, \
311 { R20R21, -1 }, { R20R21, -1 }, \
312 { R22R23, -1 }, { R22R23, -1 }, \
313 { R24R25, -1 }, { R24R25, -1 }, \
314 { R26R27, -1 }, { R26R27, -1 }, \
315 { R28R29, -1 }, { R28R29, -1 }, \
316 { R30R31, -1 }, { R30R31, -1 }, \
317 \
318 { R3, R4, R4R5, -1 }, { R4, R5, R3R4, R5R6, -1 }, \
319 { R5, R6, R4R5, R6R7, -1 }, { R6, R7, R5R6, R7R8, -1 }, \
320 { R7, R8, R6R7, R8R9, -1 }, { R8, R9, R7R8, R8R9, -1 }, \
321 { R9, R10, R8R9, -1 }, \
322 { R14, R15, -1 }, { R16, R17, -1 }, \
323 { R18, R19, -1 }, { R20, R21, -1 }, \
324 { R22, R23, -1 }, { R24, R25, -1 }, \
325 { R26, R27, -1 }, { R28, R29, -1 }, \
326 { R30, R31, -1 }, \
327 \
328 { -1 }, { -1 }, { -1 }, { -1 }, \
329 { -1 }, { -1 }, { -1 }, { -1 }, \
330 { -1 }, { -1 }, { -1 }, { -1 }, \
331 { -1 }, { -1 }, { -1 }, { -1 }, \
332
333/*
334 * According to the ABI documents, there isn't really a frame pointer;
335 * all references to data on the stack (autos and parameters) are
336 * indexed relative to the stack pointer. However, pcc isn't really
337 * capable of running in this manner, and expects a frame pointer.
338 */
339#define SPREG R1 /* stack pointer */
340#define FPREG R30 /* frame pointer */
341#define GOTREG R31 /* global offset table (PIC) */
342
343#ifdef FPREG
344#define ARGINIT (24*8) /* # bits above fp where arguments start */
345#define AUTOINIT (8*8) /* # bits above fp where automatics start */
346#define BACKAUTO /* stack grows negatively for automatics */
347#define BACKTEMP /* stack grows negatively for temporaries */
348#else
349#define ARGINIT (24*8) /* # bits above fp where arguments start */
350#define AUTOINIT (56*8) /* # bits above fp where automatics start */
351#endif
352
353/* Return a register class based on the type of the node */
354#define PCLASS(p) (1 << gclass((p)->n_type))
355
356#define GCLASS(x) ((x) < 32 ? CLASSA : ((x) < 48 ? CLASSB : CLASSC))
357#define DECRA(x,y) (((x) >> (y*6)) & 63) /* decode encoded regs */
358#define ENCRA(x,y) ((x) << (6+y*6)) /* encode regs in int */
359#define ENCRD(x) (x) /* Encode dest reg in n_reg */
360#define RETREG(x) retreg(x)
361
362int COLORMAP(int c, int *r);
363int retreg(int ty);
364
365#define SHSTR (MAXSPECIAL+1) /* short struct */
366#define SFUNCALL (MAXSPECIAL+2) /* struct assign after function call */
367#define SPCON (MAXSPECIAL+3) /* positive constant */
368
369int features(int f);
370#define FEATURE_BIGENDIAN 0x00010000
371#define FEATURE_PIC 0x00020000
372#define FEATURE_HARDFLOAT 0x00040000
373
374struct stub {
375 struct { struct stub *q_forw, *q_back; } link;
376 char *name;
377};
378extern struct stub stublist;
379extern struct stub nlplist;
380void addstub(struct stub *list, char *name);
381
382#define TARGET_STDARGS
383#define TARGET_BUILTINS \
384 { "__builtin_stdarg_start", powerpc_builtin_stdarg_start }, \
385 { "__builtin_va_arg", powerpc_builtin_va_arg }, \
386 { "__builtin_va_end", powerpc_builtin_va_end }, \
387 { "__builtin_va_copy", powerpc_builtin_va_copy }, \
388 { "__builtin_frame_address", powerpc_builtin_frame_address }, \
389 { "__builtin_return_address", powerpc_builtin_return_address },
390
391#define NODE struct node
392struct node;
393NODE *powerpc_builtin_stdarg_start(NODE *f, NODE *a, unsigned int);
394NODE *powerpc_builtin_va_arg(NODE *f, NODE *a, unsigned int);
395NODE *powerpc_builtin_va_end(NODE *f, NODE *a, unsigned int);
396NODE *powerpc_builtin_va_copy(NODE *f, NODE *a, unsigned int);
397NODE *powerpc_builtin_frame_address(NODE *f, NODE *a, unsigned int);
398NODE *powerpc_builtin_return_address(NODE *f, NODE *a, unsigned int);
399#undef NODE
400
401#define NARGREGS 8
402
403#ifdef ELFABI
404#define COM " # "
405#else
406#define COM " ; "
407#endif
Note: See TracBrowser for help on using the repository browser.