xref: /netbsd-src/external/bsd/pcc/dist/pcc/arch/arm/macdefs.h (revision 411dcbec990c8aa9c57d3bd2f4bcacadec0b1ab5)
1 /*	Id: macdefs.h,v 1.17 2015/11/24 17:35:11 ragge Exp 	*/
2 /*	$NetBSD: macdefs.h,v 1.1.1.6 2016/02/09 20:28:13 plunky Exp $	*/
3 /*
4  * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  * 3. The name of the author may not be used to endorse or promote products
16  *    derived from this software without specific prior written permission
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 /*
31  * Machine-dependent defines for both passes.
32  */
33 
34 /*
35  * Convert (multi-)character constant to integer.
36  */
37 #define makecc(val,i)	lastcon = (lastcon<<8)|((val<<24)>>24);
38 
39 /*
40  * Storage space requirements
41  */
42 #define SZCHAR		8
43 #define SZBOOL		32
44 #define SZINT		32
45 #define SZFLOAT		32
46 #define SZDOUBLE	64
47 #define SZLDOUBLE	64
48 #define SZLONG		32
49 #define SZSHORT		16
50 #define SZLONGLONG	64
51 #define SZPOINT(t)	32
52 
53 /*
54  * Alignment constraints
55  */
56 #define ALCHAR		8
57 #define ALBOOL		32
58 #define ALINT		32
59 #define ALFLOAT		32
60 #define ALDOUBLE	32
61 #define ALLDOUBLE	32
62 #define ALLONG		32
63 #define ALLONGLONG	32
64 #define ALSHORT		16
65 #define ALPOINT		32
66 #define ALSTRUCT	32
67 #define ALSTACK		32
68 
69 /*
70  * Min/max values.
71  */
72 #define	MIN_CHAR	-128
73 #define	MAX_CHAR	127
74 #define	MAX_UCHAR	255
75 #define	MIN_SHORT	-32768
76 #define	MAX_SHORT	32767
77 #define	MAX_USHORT	65535
78 #define	MIN_INT		-1
79 #define	MAX_INT		0x7fffffff
80 #define	MAX_UNSIGNED	0xffffffff
81 #define	MIN_LONG	MIN_INT
82 #define	MAX_LONG	MAX_INT
83 #define	MAX_ULONG	MAX_UNSIGNED
84 #define	MIN_LONGLONG	0x8000000000000000LL
85 #define	MAX_LONGLONG	0x7fffffffffffffffLL
86 #define	MAX_ULONGLONG	0xffffffffffffffffULL
87 
88 #define	BOOL_TYPE	INT	/* what used to store _Bool */
89 
90 /*
91  * Use large-enough types.
92  */
93 typedef	long long CONSZ;
94 typedef	unsigned long long U_CONSZ;
95 typedef long long OFFSZ;
96 
97 #define CONFMT	"#%lld"		/* format for printing constants */
98 #define LABFMT	".L%d"		/* format for printing labels */
99 #define	STABLBL	"LL%d"		/* format for stab (debugging) labels */
100 #define STAB_LINE_ABSOLUTE	/* S_LINE fields use absolute addresses */
101 
102 #undef	FIELDOPS		/* no bit-field instructions */
103 
104 /* Definitions mostly used in pass2 */
105 
106 #define BYTEOFF(x)	((x)&03)
107 #define wdal(k)		(BYTEOFF(k)==0)
108 
109 #define STOARG(p)
110 #define STOFARG(p)
111 #define STOSTARG(p)
112 
113 #define	szty(t)	(((t) == DOUBLE || (t) == LDOUBLE || \
114 	(t) == LONGLONG || (t) == ULONGLONG) ? 2 : 1)
115 
116 #define R0	0
117 #define R1	1
118 #define R2	2
119 #define R3	3
120 #define R4	4
121 #define R5	5
122 #define R6	6
123 #define R7	7
124 #define R8	8
125 #define R9	9
126 #define R10	10
127 #define R11	11
128 #define R12	12
129 #define	R13	13
130 #define R14	14
131 #define R15	15
132 
133 #define SL	R10
134 #define FP	R11
135 #define IP	R12
136 #define SP	R13
137 #define LR	R14
138 #define PC	R15
139 
140 #define R0R1	16
141 #define R1R2	17
142 #define R2R3	18
143 #define R3R4	19
144 #define R4R5	20
145 #define R5R6	21
146 #define R6R7	22
147 #define R7R8	23
148 #define R8R9	24
149 #define R9R10	25
150 
151 #define F0	26
152 #define F1	27
153 #define F2	28
154 #define F3	29
155 #define F4	30
156 #define F5	31
157 #define F6	32
158 #define F7	33
159 
160 #define NUMCLASS 3
161 #define	MAXREGS	34
162 
163 #define RSTATUS \
164 	SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG, SAREG|TEMPREG,	\
165 	SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG,	\
166 	SAREG|PERMREG, SAREG|PERMREG, SAREG|PERMREG,			\
167 	0, 0, 0, 0, 0,							\
168         SBREG|TEMPREG, SBREG|TEMPREG, SBREG|TEMPREG, SBREG,		\
169         SBREG, SBREG, SBREG, SBREG, SBREG, SBREG,			\
170 	SCREG, SCREG, SCREG, SCREG,					\
171 	SCREG, SCREG, SCREG, SCREG,					\
172 
173 #define ROVERLAP \
174 	{ R0R1, -1 },					\
175 	{ R0R1, R1R2, -1 },				\
176 	{ R1R2, R2R3, -1 },				\
177 	{ R2R3, R3R4, -1 },				\
178 	{ R3R4, R4R5, -1 },				\
179 	{ R4R5, R5R6, -1 },				\
180 	{ R5R6, R6R7, -1 },				\
181 	{ R6R7, R7R8, -1 },				\
182 	{ R7R8, R8R9, -1 },				\
183 	{ R8R9, R9R10, -1 },				\
184 	{ R9R10, -1 },					\
185 	{ -1 }, 					\
186 	{ -1 }, 					\
187 	{ -1 }, 					\
188 	{ -1 }, 					\
189 	{ -1 }, 					\
190 	{ R0, R1, R1R2, -1 },				\
191 	{ R1, R2, R0R1, R2R3, -1 },			\
192 	{ R2, R3, R1R2, R3R4, -1 },			\
193 	{ R3, R4, R2R3, R4R5, -1 },			\
194 	{ R4, R5, R3R4, R5R6, -1 },			\
195 	{ R5, R6, R4R5, R6R7, -1 },			\
196 	{ R6, R7, R5R6, R7R8, -1 },			\
197 	{ R7, R8, R6R7, R8R9, -1 },			\
198 	{ R8, R9, R7R8, R9R10, -1 },			\
199 	{ R9, R10, R8R9, -1 },				\
200 	{ -1, },					\
201 	{ -1, },					\
202 	{ -1, },					\
203 	{ -1, },					\
204 	{ -1, },					\
205 	{ -1, },					\
206 	{ -1, },					\
207 	{ -1, },					\
208 
209 #define BACKTEMP 		/* stack grows negatively for temporaries */
210 #define BACKAUTO 		/* stack grows negatively for automatics */
211 
212 #define ARGINIT		(4*8)	/* # bits above fp where arguments start */
213 #define AUTOINIT	(12*8)	/* # bits above fp where automatics start */
214 
215 #undef	FIELDOPS		/* no bit-field instructions */
216 #define TARGET_ENDIAN TARGET_LE
217 
218 /* XXX - to die */
219 #define FPREG   FP	/* frame pointer */
220 
221 /* Return a register class based on the type of the node */
222 #define PCLASS(p)	(1 << gclass((p)->n_type))
223 
224 #define GCLASS(x)	(x < 16 ? CLASSA : x < 26 ? CLASSB : CLASSC)
225 #define DECRA(x,y)      (((x) >> (y*6)) & 63)   /* decode encoded regs */
226 #define ENCRD(x)        (x)             /* Encode dest reg in n_reg */
227 #define ENCRA1(x)       ((x) << 6)      /* A1 */
228 #define ENCRA2(x)       ((x) << 12)     /* A2 */
229 #define ENCRA(x,y)      ((x) << (6+y*6))        /* encode regs in int */
230 #define RETREG(x)	retreg(x)
231 
232 int COLORMAP(int c, int *r);
233 int retreg(int ty);
234 int features(int f);
235 
236 #define FEATURE_BIGENDIAN	0x00010000
237 #define FEATURE_HALFWORDS	0x00020000	/* ldrsh/ldrh, ldrsb */
238 #define FEATURE_EXTEND		0x00040000	/* sxth, sxtb, uxth, uxtb */
239 #define FEATURE_MUL		0x00080000
240 #define FEATURE_MULL		0x00100000
241 #define FEATURE_DIV		0x00200000
242 #define FEATURE_FPA		0x10000000
243 #define FEATURE_VFP		0x20000000
244 #define FEATURE_HARDFLOAT	(FEATURE_FPA|FEATURE_VFP)
245 
246 #if 0
247 #define TARGET_STDARGS
248 #define TARGET_BUILTINS						\
249 	{ "__builtin_stdarg_start", arm_builtin_stdarg_start }, \
250 	{ "__builtin_va_arg", arm_builtin_va_arg },		\
251 	{ "__builtin_va_end", arm_builtin_va_end },		\
252 	{ "__builtin_va_copy", arm_builtin_va_copy },
253 #endif
254 
255 #define NODE struct node
256 struct node;
257 struct bitable;
258 NODE *arm_builtin_stdarg_start(const struct bitable *bt, NODE *a);
259 NODE *arm_builtin_va_arg(const struct bitable *bt, NODE *a);
260 NODE *arm_builtin_va_end(const struct bitable *bt, NODE *a);
261 NODE *arm_builtin_va_copy(const struct bitable *bt, NODE *a);
262 #undef NODE
263 
264 #define COM     "\t@ "
265 #define NARGREGS	4
266 #define NATIVE_FLOATING_POINT
267